Repository navigation
Conversation
There was a problem hiding this comment.
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.
|
See PR #28313 for a possible workaround. |
|
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.) |
|
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. |
|
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? |
This path would have two problems:
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? |
|
Well if the issue did indeed persist to chrome 114 then my plan to drop support for chrome 85 wouldn't work anyway, right? |
|
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. |
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>
6931fd6 to
e4f1c9d
Compare
|
I'll close this for now in favor of a smaller step #28366 first. |
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.