The Problem
In my project built with Rust compiled to WebAssembly, I started seeing errors like this that caused a crash - but only when it was compiled in debug mode:
wavetable.wasm-011dbbd6:0x17b89 Uncaught RuntimeError: memory access out of bounds
at wavetable.wasm._ZN9wavetable2fm7effects14EffectInstance10from_parts17h321e4433e1216e56E (wavetable.wasm-011dbbd6:0x17b89)
at wavetable.wasm._ZN9wavetable2fm7effects11EffectChain10set_effect17h969349e414104e9eE (wavetable.wasm-011dbbd6:0x1ba60)
at wavetable.wasm.fm_synth_set_effect (wavetable.wasm-011dbbd6:0x314d3)
at FMSynthAWP.port.onmessage (FMSynthAWP.js:171:37)
When compiling in release mode, the code ran just fine.
The decompiled debug-mode Wasm at the point of the crash looked like this:

