-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
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
Add call trampoline to work around bad fpcasts on Emscripten #91318
Comments
WASM cannot handle function calls with bad function pointer casts yet. Hood Chatham explained the issue in Pyodide patch https://github.com/pyodide/pyodide/blob/0.19.1/cpython/patches/0001-call-trampolines-to-handle-fpcast-troubles.patch --- By contrast, typical native ABIs handle function pointer casts very gracefully: The Python ecosystem is full of code which contain function pointer casts. We wish to avoid these costs. Patching the packages is prohibitively time There is a best of both worlds solution. It is possible to define an ABI which In the meantime, most bad function pointer calls happen in a small number of Bad function pointer casts lead to fatal runtime errors like this: worker.js onmessage() captured an uncaught exception: RuntimeError: function signature mismatch I propose to include the downstream patch from Pyodide but make the call trampoline feature opt-in. An opt-in allows Pyodide to use the trampolines in production while we can test core and 3rd party modules without the trampoline easily. |
Note that there are still Python test suite failures in emscripten without these trampolines enabled, for instance test_imp fails. The only trampoline needed to pass the core test suite is _PyImport_InitFunc_TrampolineCall. |
Interesting, can you pin point the buggy function pointer? If you link with -gsource-map and deploy the map file, your browser should give you a decent stack trace. |
I'm having trouble pinpointing the bad function pointer because chrome cuts off the end of the wasm file with:
Maybe I should follow the directions here, since this is a consistent nuisance. I looked into this before at some point and IIRC the issue is that one initialization code path hands the Init function a spec but the a different path doesn't give it the spec. It wasn't obvious how to fix the problem. |
As an update, building the chrome devtools with the wasm limit set to 12Mb following that guide worked fantastic. Highly recommend it. (Though there are a few paths that are out of date, I had to consult google's devtools docs.) The problem is that cpython/Modules/_testmultiphase.c Line 897 in 082d349
Minimized trigger:
Causes |
Actually, I think the _PyImport_InitFunc trampoline call is only there as a work around for the problematic |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: