Repository navigation
Description
We're encountering a new issue in our web app since installing ios 26.2 rc as well as the preceding beta versions. This is probably a webkit regression rather than an emscripten bug, but posting here in case others are experienced the same issue and hoping to get a little insight from the wasm / emscripten side.
Our app is multi-threaded and uses growable memory. It works fine in previous ios versions through the current 26.1, but now with 26.2 we are seeing immediate memory-related crashes once wasm processing begins. Rather than out-of-memory, the crashes are due to RuntimeError: Out of bounds memory access buried deep within a dependency library. It has something to do with new allocations - in some cases just a std::vector::resize - but it's been challenging to pinpoint thus far. Release and debug builds both exhibit the problem.
Switching to fixed-memory solves the issue, as does forcing single-threaded mode (pthreads still enabled in the build but limiting threads to 1 at the application level). But the combination of growable memory + multiple threads consistently triggers this crash.
We'll continue to try isolating the problem and come up with a MRE to share here. But in the meantime I wanted to report this to see if there's any corroboration that might help with debugging and/or filing the right bug report.
emcc -v:
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 4.0.21 (d6f42310010ddec0753a69bab01a4b33aae255b7)
clang version 22.0.0git (https:/github.com/llvm/llvm-project 60513b8d6ebacde46e8fbe4faf1319ac87e990e3)
Target: wasm32-unknown-emscripten
Thread model: posix
command line from cmake:
em++ -O3 -DNDEBUG -flto --bind --no-entry --gc-sections -sFILESYSTEM=0 -sEXPORT_ES6=1 -sENVIRONMENT=web,worker -v -pthread -sPTHREAD_POOL_SIZE_STRICT=0 -SCROSS_ORIGIN=1 -sMALLOC=mimalloc -sALLOW_MEMORY_GROWTH=1 --closure 1 -sASSERTIONS=1 -sNO_DISABLE_EXCEPTION_CATCHING --emit-tsd full.d.ts @CMakeFiles/full.simd.threads.growable.dir/objects1.rsp -o full.simd.threads.growable.js @CMakeFiles/full.simd.threads.growable.dir/linkLibs.rsp
bin/wasm-ld -o full.simd.threads.growable.wasm -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-cxx-exceptions -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr /tmp/tmph1lclr0xlibemscripten_js_symbols.so --import-memory --shared-memory --strip-debug -u__cxa_atexit --export=emscripten_stack_get_end --export=emscripten_stack_get_free --export=emscripten_stack_get_base --export=emscripten_stack_get_current --export=emscripten_stack_init --export=_emscripten_stack_alloc --export=__getTypeName --export=_embind_initialize_bindings --export=_emscripten_thread_free_data --export=_emscripten_thread_crashed --export=__cxa_can_catch --export=__cxa_increment_exception_refcount --export=__cxa_decrement_exception_refcount --export=setThrew --export=__cxa_free_exception --export=__wasm_call_ctors --export=_emscripten_tls_init --export=_emscripten_thread_init --export=_emscripten_stack_restore --export=emscripten_stack_set_limits --export=_emscripten_thread_exit --export=__get_exception_message --export=free --export-if-defined=__start_em_asm --export-if-defined=__stop_em_asm --export-if-defined=__start_em_lib_deps --export-if-defined=__stop_em_lib_deps --export-if-defined=__start_em_js --export-if-defined=__stop_em_js --export-if-defined=main --export-if-defined=__main_argc_argv --export-if-defined=fflush --export-table -z stack-size=65536 --max-memory=2147483648 --initial-memory=16777216 --no-entry --no-stack-first --table-base=1 --global-base=1024 -lembind-mt-rtti <lots of objects here> -lGL-mt-getprocaddr -lal -lhtml5 -lstubs-debug -lnoexit -lc-mt-debug -lmimalloc-mt -lcompiler_rt-mt -lc++-debug-mt -lc++abi-debug-mt -lsockets-mt
Activity
dr-matt commentedon Dec 16, 2025
iOS 26.2 has officially been released and this bug is still present. I was able to create a MRE that (for me) triggers the error. This was run on an iphone 13, you may need to raise the number of threads and/or chunk sizes to reproduce on other hardware.
I compiled with:
The behavior I see is the same out of bounds memory access as in my original application.
Maybe of interest:
I hope this is enough information for emscripten experts to begin taking a look. It would be great to verify that this is a regression introduced by ios 26.2 so that we can file a bug report, and maybe identify a better workaround than single-threaded or fixed-memory.
[edited to avoid blocking main thread]
sbc100 commentedon Dec 16, 2025
If you structure you main entry point so that it doesn't block the main thread does that help?
One way to do that it simply to add
-sPROXY_TO_PTHREAD.Anther way to do it would be to make
std::vector<std::thread> threads;global and remove the.joincalls.dr-matt commentedon Dec 16, 2025
You're right, this does block the main thread (it was put together quickly), but the original application doesn't block, and unfortunately adding
PROXY_TO_PTHREADdoes not change the error behavior.Vincentzyx commentedon Dec 21, 2025
kleisauke commentedon Dec 23, 2025
Sounds like this is the same bug as https://bugs.webkit.org/show_bug.cgi?id=304386, which was fixed with commit WebKit/WebKit@192a3bc.
This issue can also be reproduced with Bun v1.3.5. Running tests against wasm-vips produces the following errors:
(and related variants)
dr-matt commentedon Dec 23, 2025
@Vincentzyx if you need multiple threads, the only workaround I know of is to disable growable memory (
-sALLOW_MEMORY_GROWTH=0) and set a large enough fixed memory size for your application via-sINITIAL_MEMORY.kripken commentedon Dec 24, 2025
This may also be related to
https://bugs.webkit.org/show_bug.cgi?id=303387
which looks like it was recently fixed.
If there is a nightly build of Bun perhaps that could be tested? (@kleisauke - very cool that Bun can be used for this kind of thing!)
kleisauke commentedon Dec 24, 2025
Ah, indeed. WebKit issue https://bugs.webkit.org/show_bug.cgi?id=303387 appears to be more relevant when building with
-sALLOW_MEMORY_GROWTH(wasm-vips still builds without this linker flag).It looks like you can use Bun's canary builds for this. For example:
However, this doesn't seem to resolve the issue. I suspect that https://github.com/oven-sh/WebKit needs to be updated first to include the commits referenced in those WebKit issues.
milky2028 commentedon Jan 29, 2026
Hello, for anyone else in the future seeing this issue, I work on Photoshop Web and we solved this problem by determining at runtime if the browser is a broken Safari version, then changing the initial memory allocation based on that. As of this writing, the fix is out in Safari Technology Preview and will hopefully ship with Safari 26.3.
Our fix:
Alexufo commentedon Feb 17, 2026
It seems that version 23.3 solves the issue, but do you have multi-threaded speed? It seems that the speed is the same as single-threaded.
potential fix for emscripten-core/emscripten#25905
rlvm: start with 256 MB so iPhone Safari doesn't crash on boot; resto…