emscripten-core / emscripten-core/emscripten
Safari + Unaligned Load + Asyncify = Page memory leak
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
This is likely a Safari bug, but because it only triggers when using certain arguments to Emscripten I am cross posting here. Basically under certain circumstances, when WASM performs an unaligned load, and Asyncify is enabled, and you are using Safari, it triggers a continuous memory leak even after all WASM threads have completed eventually causing an out-of-memory crash. There are a few libraries I have encountered that trigger this, but GLSlang is one I was able to quickly [fix](https://github.com/KhronosGroup/glslang/pull/4137) and verify it appears to stops the leak.
Repro: https://github.com/jamesdolan/safari_leak
Adding the problematic function(s) to `ASYNCIFY_REMOVE` also avoids the issue FWIW.
**Version of emscripten/emsdk:**
```
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 4.0.22 (0f3d2e62bccf8e14497ff19e05a1202c51eb0c65)
clang version 22.0.0git (https:/github.com/llvm/llvm-project c7706d9472fe880ba1d3418919ad4185710c9559)
Target: wasm32-unknown-emscripten
Thread model: posix
```
Contributor guide
Assessment
This issue has not been assessed yet.