-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix async futex wait in WASM worker dose not keep runtime alive #20306
Fix async futex wait in WASM worker dose not keep runtime alive #20306
Conversation
Fix asynchronous futex wait `emscripten_atomic_wait_async` in WASM worker dose not keep runtime alive.
c062d80
to
a4e5704
Compare
#if !MINIMAL_RUNTIME | ||
'$runtimeKeepalivePush', '$runtimeKeepalivePop', | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is not needed. The compiler adds the runtime-keepalive stuff automatically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, after testing, the compiler does not automatically add runtime-keepalive stuff, because library_wasm_worker.js
is not in the core system libraries of modules.js
, so need to add a reference here manually.
Line 37 in f9ce05b
// Core system libraries (always linked against) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, it's not in the core system libraries always linked against, but when you enable wasm workers then it is added to the list. And then it should be processed like any other library. That is, there should be no difference between a core library and a non-core library if both are linked in. Is that not so?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, it's not in the core system libraries always linked against, but when you enable wasm workers then it is added to the list. And then it should be processed like any other library. That is, there should be no difference between a core library and a non-core library if both are linked in. Is that not so?
According to the modules.js
, when enable WASM worker support, it doesn't seem to be automatically added to the core library.
As a result, dependencies must be added manually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where do you see that? (I see no mention of wasm workers in modules.js
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @kripken is right, we hopefully don't need these __deps
here.. if you remove the __deps
here what error do you see?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than the comment this looks right to me.
@sbc100 what's the best way to test keepalive usage?
I think this could be the right fix. I guess we don't have a lot of testing for this API. If this is a bug it should also effect pthreads too, not just wasm workers right? |
Oh I guess We do have some tests for it in @juj for wasm worker input. |
If the In addition, although the thread created by wasm worker does not have this problem, but it is still incorrect for the runtime keepalive. |
Wasm Workers do not start with a "thread main" function, so they don't have a concept of the runtime liveness tracking. (in other words, the runtime is always alive) If you are seeing the runtime being shut down in a wasm worker, that would be a bug. The runtime shutdown functions should not be getting called in wasm workers. |
Oh now I think I understand - the fix here is intended to be "Fix async futex wait in pthreads does not keep runtime alive"? LGTM. |
@medns, if this is correct, can you replace Also, can we add a test for this? I'm guessing a new test in new test in |
I think that #20404 subsumes this change, I hope thats, it kind of fell out the fact that I moved that API and had to make it testable under pthreads. |
I think so yes. Thanks for working on this! |
Fix asynchronous futex wait
emscripten_atomic_wait_async
in WASM worker dose not keep runtime alive.