Skip to content

Blacklist multithreading on Chrome < 132 and Node.js < 24 - #28330

Closed
juj wants to merge 5 commits into
emscripten-core:mainfrom
juj:fix_atomic_wait_old_chrome
Closed

juj wants to merge 5 commits into
emscripten-core:mainfrom
juj:fix_atomic_wait_old_chrome

Conversation

@juj

@juj juj commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator
  • Require Chrome 132 for multithreaded builds

The Liftoff baseline compiler of V8 11.0 - 11.4 (Chrome 110 - 114)
miscompiles the memory.atomic.wait32 and memory.atomic.wait64
instructions (https://crbug.com/1432453). All the releases of Node.js 20
have V8 11.3, so they have this bug as well.

Chrome versions before 132 miscompile the atomic.rmw.and/or/xor
instructions when they access a constant memory address at 2GB or above
(https://crbug.com/378779897). So do all the releases of Node.js 22 and 23
(V8 12.4 and 12.9), where the V8 regression test for this bug crashes
with a segmentation fault.

Restore Feature.THREADS in the feature matrix with a minimum Chrome
version of 132 and a minimum Node.js version of 24, and enable it for
builds that use shared memory (-pthread or -sWASM_WORKERS). Such builds
now default to MIN_CHROME_VERSION=132 and MIN_NODE_VERSION=240000.
Explicitly targeting an older Chrome or Node.js version still works, but
emits a -Wcompatibility warning.

On the test side, skip multithreaded browser tests when the browser
under test does not support Feature.THREADS, since assertion builds
refuse to run in a browser that is older than MIN_CHROME_VERSION. For
that, browser_should_skip_feature() now also takes the Chrome version
into account; so far it only checked Firefox and Safari.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the minimum required Chrome version to 115 for multithreaded builds to avoid a known Liftoff compiler bug in Chrome 110-114. It introduces a THREADS feature to the feature matrix and updates browser test utilities to skip multithreaded tests on unsupported browser versions. Feedback on the changes includes improving the robustness of the uses_shared_memory flag parser to handle separate -s arguments (e.g., ['-s', 'WASM_WORKERS']) and using .get() with a default value when retrieving browser versions from the feature matrix to prevent potential KeyError exceptions.

Comment thread test/browser_common.py Resolved
Comment thread test/browser_common.py Resolved
@kleisauke

Copy link
Copy Markdown
Collaborator

See PR #28313 for a possible workaround.

@juj

juj commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator Author

The workarounds there seem to relate to a different bug than the ones marked here?

@kleisauke

Copy link
Copy Markdown
Collaborator

The workarounds there seem to relate to a different bug than the ones marked here?

https://crbug.com/1432453 redirects to https://issues.chromium.org/issues/40902945, which is the same issue I referred to in #28313 (comment). However, my comment applies only to 83bc7ab (and the PR description), not to 6931fd6.

(It's somewhat odd that PR #28313 mentions Chrome 85 (and V8 8.5). If the PR is intended as a workaround for https://crbug.com/1432453, the relevant Chrome versions that would be affected are 110-114.)

@juj juj changed the title Blacklist multithreading on Chrome < 115 Blacklist multithreading on Chrome < 132 Nov 20, 2026
@juj

juj commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator Author

There's another bug https://crbug.com/378779897 that affects later Chromes.

I did consider gating that behind being paired with > 2GB Memories, but not sure if that was worth the complexity.

@sbc100

sbc100 commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator

Clearly there are folks who are shipping and what to continue to ship multi-threaded code to older chrome version.

Otherwise #28313 would not have been opened.

How about we land #28313 .. and then consider bumping this for the next emscripten release. Then we can tell folks targetting chrome 85 to use 7.0.1?

@juj

juj commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator Author

How about we land #28313 .. and then consider bumping this for the next emscripten release. Then we can tell folks targetting chrome 85 to use 7.0.1?

This path would have two problems:

  1. all users would get the codegen pessimization even when the issue only affects Chrome < 115 (a three year old Chrome version), and
  2. if we immediately bump, that would leave those users behind who are proposing the workaround.

I posted #28344 which would not result in codegen pessimization, and will not leave users behind who care about that workaround.

It is more complex, but at least we'd cater to both crowds and the complexity would then be kept in the compiler, rather than the generated code.

Would #28344 be too complex?

@sbc100

sbc100 commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator

Well if the issue did indeed persist to chrome 114 then my plan to drop support for chrome 85 wouldn't work anyway, right?

@juj

juj commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator Author

If we landed #28344, I'll close this PR and recast the remaining Chrome 132 problem into a different form that would also cater to Safari MEMORY4GB issues.

juj and others added 5 commits November 21, 2026 01:34
The Liftoff baseline compiler of V8 11.0 - 11.4 (Chrome 110 - 114)
miscompiles the memory.atomic.wait32 and memory.atomic.wait64
instructions (https://crbug.com/1432453): it widens the value stack
slot of the address operand, which can overwrite a neighboring slot.
In unoptimized builds emscripten_atomic_wait_u32() and
emscripten_atomic_wait_u64() then return ATOMICS_WAIT_OK regardless of
the value in memory or the timeout, and these tests fail with

  Assertion failed: ret == ATOMICS_WAIT_NOT_EQUAL

This was fixed in V8 11.5 (Chrome 115).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The Liftoff baseline compiler of V8 11.0 - 11.4 (Chrome 110 - 114)
miscompiles the memory.atomic.wait32 and memory.atomic.wait64
instructions (https://crbug.com/1432453), which breaks waiting on
futexes in unoptimized builds.

Restore Feature.THREADS in the feature matrix with a minimum Chrome
version of 115, and enable it for builds that use shared memory
(-pthread or -sWASM_WORKERS). Such builds now default to
MIN_CHROME_VERSION=115. Explicitly targeting an older Chrome version
still works, but emits a -Wcompatibility warning.

On the test side, skip multithreaded browser tests when the browser
under test does not support Feature.THREADS, since assertion builds
refuse to run in a browser that is older than MIN_CHROME_VERSION. For
that, browser_should_skip_feature() now also takes the Chrome version
into account; so far it only checked Firefox and Safari.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Address review: uses_shared_memory() only recognized the combined
`-sFOO` form of settings.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The Liftoff compiler of Chrome versions older than 132 miscompiles the
atomic.rmw.and/or/xor instructions when they access a constant memory
address at 2GB or above (https://crbug.com/378779897): the address is
computed in the scratch register, which the instruction sequence then
clobbers before using it, so the operation reads and writes some other
memory location.

Since musl's locks use these operations, multithreaded programs with a
heap over 2GB corrupt memory on those versions. In browser_2gb on
Chrome 123 this shows up as test_pthread_gcc_atomic_* timing out,
test_pthread_lsan_* aborting with a corrupted heap, and
test_wasm_worker_and_pthread failing its thread id assertion.

V8 fixed this in 13.3 (Chrome 133) and merged the fix back to Chrome
132, and to later builds of Chrome 130 and 131. Raise the minimum
Chrome version of Feature.THREADS from 115 to 132, which is the first
version where every build has the fix.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Node.js has the same two V8 Liftoff bugs that Chrome has:

- All the releases of Node.js 20 have V8 11.3, which miscompiles the
  atomic.wait instructions (https://crbug.com/1432453). The first version
  with the fix is Node.js 21.0.0.
- All the releases of Node.js 22 and 23 have V8 12.4 and 12.9, which
  miscompile the atomic.rmw.and/or/xor instructions when they access a
  constant memory address at 2GB or above (https://crbug.com/378779897).
  The V8 regression test for this crashes Node.js 22.23.5 and 23.11.1 with
  a segmentation fault. The first version with the fix is Node.js 24.0.0.

So set the minimum Node.js version of Feature.THREADS to 24, which is the
first version from which no release has either of these bugs. Builds that
use shared memory now default to MIN_NODE_VERSION=240000, and explicitly
targeting an older Node.js version emits a -Wcompatibility warning.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@juj
juj force-pushed the fix_atomic_wait_old_chrome branch from 6931fd6 to e4f1c9d Compare November 20, 2026 23:51
@juj juj changed the title Blacklist multithreading on Chrome < 132 Blacklist multithreading on Chrome < 132 and Node.js < 24 Nov 20, 2026
@juj

juj commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator Author

I'll close this for now in favor of a smaller step #28366 first.

@juj juj closed this Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants