Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
EMTERPRETIFY + EMULATED_FUNCTION_POINTER_CASTS + WASM can mess up f32 indirect call args #6759
After many hours of debugging I'm facing the following situation:
I tried to reproduce the issue with a simple test case but it works correctly.
I'll try and investigate further, meanwhile any tip on how to debug this are appreciated :)
Got it. It involves calling a function pointer in an Emterpreter binary with
Here's a minimal test case:
This is nasty o_O
Thanks! Here's a slightly smaller testcase:
Turns out the issue here is that the emterpreter assumes asm.js types: i32 and f64, nothing else. So it converts float params to double. Normally this doesn't matter (using doubles to represent floats always does so with full precision), but emulated function pointers actually does care about matching those up, as it uses an ABI that is sensitive to that - in our case here, the call (created by
I suspect we've just never tested the combination of EMTERPRETIFY + EMULATED_FUNCTION_POINTER_CASTS + WASM (wasm matters since the ABI is different in asm.js, in fact exactly because asm.js only has i32s and f64s - so it can use f64s for everything, with no f32s or i64s to worry about).
For your immediate issue, I'd suggest disabling wasm (
But it would be good to fix this. One option is to disallow f32s in function pointer calls, perhaps (that would mean changing
Btw, you can do
I confirm the asm.js version works correctly (just needing 3x more time to compile T_T).
When you say "One option is to disallow f32s in function pointer calls", would that mean that my current code with float-s would be unsupported?