Fix emscripten_yield to avoid calling timers from Wasm Workers#26750
Merged
Conversation
Collaborator
|
Fantastic 👍 |
juj
approved these changes
Apr 22, 2026
Timers are only ever run on them main runtime thread. In emscripten-core#26655 I added an assertion to ensure that `_emscripten_check_timers` is only called from the main runtime thread. This broke tests such as `lto0.test_wasm_worker_futex_wait`. The reason this test only failed in the LTO build on not under core0 is due to a bug in LTO which defeats the weak alias mechanism that is designed to only pull in the timer code when needed: ``` weak_alias(dummy, _emscripten_check_timers); ``` This changes fixes the stub version of `emscripten_yield_stub` so that it avoids calling `_emscripten_check_timers` from Wasm Workers. Note: In a Wasm Workers build one can register and use timers from the main thread, but one cannot register a timer from a Wasm Worker (because _setitimer_js is a proxied func).
6ec8049 to
cbbf93c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Timers are only ever run on them main runtime thread. In #26655 I added an assertion to ensure that
_emscripten_check_timersis only called from the main runtime thread. This broke tests such aslto0.test_wasm_worker_futex_wait.The reason this test only failed in the LTO build on not under core0 is due to a bug in LTO which defeats the weak alias mechanism that is designed to only pull in the timer code when needed:
This changes fixes the stub version of
emscripten_yield_stubso that it avoids calling_emscripten_check_timersfrom Wasm Workers.Note: In a Wasm Workers build one can register and use timers from the main thread, but one cannot register a timer from a Wasm Worker (because _setitimer_js is a proxied func).
Fixes: #26749