Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory access out of bounds on Chrome 91 #14538

Closed
thedreamwork opened this issue Jun 25, 2021 · 4 comments
Closed

Memory access out of bounds on Chrome 91 #14538

thedreamwork opened this issue Jun 25, 2021 · 4 comments

Comments

@thedreamwork
Copy link

Chrome 91 on Android also managed to break WebAssembly memory growth which affects our sites too, so it's been a rough couple of weeks working around browser bugs for us. https://bugs.chromium.org/p/v8/issues/detail?id=11863

and #14391

Is there a perfect workaround on Chrome 91?

@lethal-guitar
Copy link

lethal-guitar commented Jul 2, 2021

A workaround that worked for me is to pre-allocate enough memory by compiling with -s INITIAL_MEMORY=64mb (adjust for the memory needs of your app), to avoid the need for run-time memory growth. Maybe it helps someone else as well?

@tangobravo
Copy link

tangobravo commented Jul 4, 2021

The original text in this bug report comes from a comment I posted on Hacker News, about a bug in Safari's indexedDB implementation in iOS 14.6. You can see the context here: https://news.ycombinator.com/item?id=27512685

In terms of our workaround for this one, we do something similar to @lethal-guitar in terms of trying to ensure the initial allocation is large enough to avoid memory growth. If you know exactly your memory needs then just increasing INITIAL_MEMORY is probably the right solution.

For us the exact memory requirements aren't known up-front and we just want as much memory as possible. The problem of just hard-coding a large INITIAL_MEMORY is the allocation may fail (especially on lower-RAM mobile devices) so you might end up failing to run at all, when in fact it would have worked with less memory.

So our workaround is to manage allocating the WebAssembly.Memory ourselves, starting with a large request (512MB) and reducing the amount requested in 64MB steps if an exception is thrown. We then pass that in as Module['wasmMemory'] when initializing the emscripten code (it's necessary to pass -s IMPORTED_MEMORY when compiling with newer versions of emscripten to allow passing in the memory from Javascript).

@Calinou
Copy link

Calinou commented May 27, 2022

This is likely fixed by now, so this issue can be closed.

@kripken
Copy link
Member

kripken commented May 27, 2022

Thanks @Calinou , closing.

@kripken kripken closed this as completed May 27, 2022
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

No branches or pull requests

5 participants