Comment #27 on issue 11863 by si...@
zappar.com: Wasm memory growth causes heap corruption
https://bugs.chromium.org/p/v8/issues/detail?id=11863#c27I can't allocate much time to this personally, but it would be good to get to the bottom of it - we're still avoiding memory growth on our sites by allocating a large chunk up-front, just in case.
I think the easiest way to track down / repro / bisect will be with android builds and the simple test cases that were 100% reproducible in Android Chrome 91. It's possible the other larger test cases are suffering a similar bug, but they seem much harder to reproduce.
So following the instructions at
https://www.chromium.org/getting-involved/download-chromium/#downloading-old-builds-of-chrome-chromium I looked up Chrome version 91.0.4472.88 and got the following info:
Commit: 7786c26efaeaed9406b32952d029a1c47fb3fa48
Branch Base Commit: 3d60439cfb36485e76a1c5bb7f513d3721b20da1
Branch Base Position: 870763
V8 Commit: fd856cebb3515699d942d0f2517f6658a0cf720b
V8 Version: 9.1.269.28
V8 Position: 56
Skia Commit: 71fcb16fc206466727cb49cbf318b765f8a9d5a7
870756 was the preceding build available at the continuous build archive, which I found here:
https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Android/870756/I have verified that the simple test case still reproduces the bug in that build of Chromium (using ChromePublic.apk). I've also rebuilt the test with the latest emscripten (3.1.3) and it still reproduces there. The exact offset that causes the corruption is a bit different again with this build (somewhere around 1730 bytes after the initially-allocated 8MB) so I've adjusted main.cpp to be less targeted at one particular offset.
As discovered above, TurboFan is required. Setting "Disable baseline compiler" in chrome://flags will ensure TurboFan is used, even on the first load.
Is there a similar continuous build archive just for V8? I've built from source in the past but don't have a linux build environment set up right now.
I think the test should be able to run standalone via d8; my first attempt would be something like this that I've used for running benchmarking code in the past:
./d8 --no-wasm-tier-up --no-liftoff --predictable test.js
Attached the main.cpp test case, the compiled test.js and test.wasm, and a more minimal html file that just hooks up the console output to a <textarea>.
Compilation command line: emcc -O2 -s INITIAL_MEMORY=8mb -s ALLOW_MEMORY_GROWTH=1 main.cpp -o test.js
Hosted version of minimal page:
https://tangobravo-public.s3.eu-west-1.amazonaws.com/v8-bug-11863/index.wasmOver to someone on the V8 team to try to reproduce with the d8 commit shown above, or to bisect based on the Chromium continuous builds archive. I feel like I've done my part on this one now...
Attachments:
main.cpp 709 bytes
minimal-shell.html 1.2 KB
test.js 75.9 KB
test.wasm 122 KB