analysis
So we have identified how the calls are happening; the thrown exceptions even agrees with us in the call stack, but for whatever reason, we are not (yet) catching the exception.
anon80458984:
I am not clear if the second "Uncaught (in promis) RuntimeError: unreachable" is a Rust or a JS exception.
This is the result of calling std::process::abort()
(which on wasm codegens to the unreachable
instruction), which Rust does on panics in case of -Cpanic=abort
.
Furthermore, because this is a Rust panic, does it mean we don't actually hit the wasm 4GB limit? I.e. is the allocator in generated Rust/wasm seeing that it is about to hit the 4GB limit -- and then deciding to abort before actually hitting the 4GB limit ? This might explain why this is a Rust panic/abort rather than a JS/Wasm error.
anon80458984:
Furthermore, because this is a Rust panic, does it mean we don't actually hit the wasm 4GB limit? I.e. is the allocator in generated Rust/wasm seeing that it is about to hit the 4GB limit -- and then deciding to abort before actually hitting the 4GB limit ? This might explain why this is a Rust panic/abort rather than a JS/Wasm error.
The grow_memory instruction used for growing the heap may return an error in OOM cases. Rust catches this and prints an error if this happens before aborting. In your specific case I think it was a capacity overflow (which basically means attempting to allocate more than fits in a usize (or isize?)) rather than a failed memory allocation though.