A miscompile issue caused by a finite loop
zyz9740 opened this issue · 1 comments
You can try this one. I don't know why cheerp doesn't print.
This is a known issue in the fact that there is a mismatch between LLVM's IR and WebAssembly provided opcodes.
For perfomance reasons, the current default is that unsafe conversion are allowed, but might results in WebAssembly runtime traps.
Executing this with node
, the following error is raised:
RuntimeError: float unrepresentable in integer range
at wasm://wasm/000149b6:wasm-function[97]:0x3e4f
at bJ (/home/carlo/work/bug126/10-10-15-59/X/crash-bug-10-11/finite_loop_miscompile/random_cheerp.js:1:1205)
at /home/carlo/work/bug126/10-10-15-59/X/crash-bug-10-11/finite_loop_miscompile/random_cheerp.js:1:1749
User side the escape hatch is providing the flag -cheerp-avoid-wasm-traps
at compile time, that would emulate saturating conversion between floating point and integers (at the cost of slightly more verbose and slower code).
Adding -cheerp-avoid-wasm-traps
works as intended in your testcase.
I will review whether better documentation for this option might be required, but for now I will consider this closed.