Repository navigation
Conversation
vzhn
marked this pull request as draft
November 28, 2026 11:39
vzhn
force-pushed
the
fix-atomics-wait-result
branch
2 times, most recently
from
November 28, 2026 11:43
f3d549b to
c323249
Compare
vzhn
marked this pull request as ready for review
November 28, 2026 11:48
vzhn
force-pushed
the
fix-atomics-wait-result
branch
from
November 28, 2026 12:01
c323249 to
6e1d535
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.
Fixes #636 (
Atomics.wait()returns "timed-out" for a waiter thatAtomics.notify()woke).js_atomics_wait()took its result from the return code ofpthread_cond_wait()/pthread_cond_timedwait(). A timeout that races withAtomics.notify()gave "timed-out" although notify counted the waiter, and a spurious wake-up gave "ok" with no notify. Now the wait loops while the waiter is still linked, and the result is "ok" exactly whenAtomics.notify()removed it, asAtomics.waitAsync()already does withasync_state. The first timed wait uses the requested timeout as before; after a wake-up the remaining time is taken from a deadline rounded up to the next ms, so the wait never ends before the (integer ms) timeout. A pthread error other than a timeout also ends the loop, so it cannot spin with the mutex held.js_atomics_get_time_ms()gets a forward declaration sojs_atomics_wait()can use it.Tested on Linux x86_64 (glibc 2.43); the
__APPLE__path was not built.pthread_cond_wait()/pthread_cond_timedwait()forced to fail with EINVAL (LD_PRELOAD shim): the waits return "timed-out" at once instead of spinning-a, 389 tests): 0 errors, before and aftermake test: passes (withTZ=UTC; test_intl.js depends on the local time zone)