New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EMTERPRETIFY + EMULATED_FUNCTION_POINTER_CASTS + WASM can mess up f32 indirect call args #6759
Comments
Got it. It involves calling a function pointer in an Emterpreter binary with Here's a minimal test case: embug-call.c:
embug-set.c:
compile:
Expected:
Result:
This is nasty o_O |
Note: when switching all parameters to |
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? |
Sorry, I wasn't clear there: I meant that we'd automatically translate f32s to f64s for such calls. That's what asm.js does anyhow, and it's probably not that much overhead compared to what the emulation does overall. |
This is because of a bug in emscripten, see emscripten-core/emscripten#6759 for the details.
This is because of a bug in emscripten, see emscripten-core/emscripten#6759 for the details.
This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 7 days. Feel free to re-open at any time if this issue is still relevant. |
The issue is still present in Emterpreter. |
@kripken do you think this is worth fixing? Labeling as fastcomp only. |
I think it's probably too late in fastcomp's lifecycle to be worth fixing - wasm backend + Asyncify is the replacement. But if someone needs this and has a patch I wouldn't object. |
This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant. |
After many hours of debugging I'm facing the following situation:
.o
1.0,1.0,1.0,1.0
0.0,0.0,0.0,0.0
(resulting in an extremely puzzling black screen)I tried to reproduce the issue with a simple test case but it works correctly.
From what I see in the Cython-generated code, the function signatures match (I suspected some double->float mismatch but that doesn't seem to be the case).
I'll try and investigate further, meanwhile any tip on how to debug this are appreciated :)
The text was updated successfully, but these errors were encountered: