You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Rust compiler generates Wasm trigonometry functions with unmangled names. Trying to export a wasm-bindgen function with one of those names causes a symbol conflict where the exported function just calls itself, resulting in a stack overflow.
Compiling wbg-sin v0.0.0
Finished release [optimized] target(s) in 0.24s
-0.9165215479156338
Actual Behavior
Compiling wbg-sin v0.0.0
Finished release [optimized] target(s) in 0.51s
wasm://wasm/cc173f36:1
RangeError: Maximum call stack size exceeded
at sin (wasm://wasm/cc173f36:wasm-function[0]:0x52)
at sin (wasm://wasm/cc173f36:wasm-function[0]:0x55)
at sin (wasm://wasm/cc173f36:wasm-function[0]:0x55)
at sin (wasm://wasm/cc173f36:wasm-function[0]:0x55)
at sin (wasm://wasm/cc173f36:wasm-function[0]:0x55)
at sin (wasm://wasm/cc173f36:wasm-function[0]:0x55)
at sin (wasm://wasm/cc173f36:wasm-function[0]:0x55)
at sin (wasm://wasm/cc173f36:wasm-function[0]:0x55)
at sin (wasm://wasm/cc173f36:wasm-function[0]:0x55)
at sin (wasm://wasm/cc173f36:wasm-function[0]:0x55)
Node.js v18.15.0
Importantly, note that changing the exported function name from sin to sine yields the Expected Behavior described above. But with the function named sin, the actual implementation of sine becomes dead code and gets optimized away, yielding this very tiny disassembled Wasm as can be seen by running wasm2wat wbg/wbg_sin_bg.wasm:
Describe the Bug
The Rust compiler generates Wasm trigonometry functions with unmangled names. Trying to export a
wasm-bindgen
function with one of those names causes a symbol conflict where the exported function just calls itself, resulting in a stack overflow.Steps to Reproduce
https://github.com/samestep/wbg-sin
gh repo clone samestep/wbg-sin
cd wbg-sin
./run.sh
Expected Behavior
Actual Behavior
Additional Context
See also #2338 and #2806.
Importantly, note that changing the exported function name from
sin
tosine
yields the Expected Behavior described above. But with the function namedsin
, the actual implementation of sine becomes dead code and gets optimized away, yielding this very tiny disassembled Wasm as can be seen by runningwasm2wat wbg/wbg_sin_bg.wasm
:The text was updated successfully, but these errors were encountered: