Add call trampoline to work around bad fpcasts on Emscripten #91318
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
assignee = None closed_at = <Date 2022-03-30.19:28:48.089> created_at = <Date 2022-03-30.11:11:40.210> labels = ['interpreter-core', 'build', '3.11'] title = 'Add call trampoline to work around bad fpcasts on Emscripten' updated_at = <Date 2022-04-02.02:37:08.500> user = 'https://github.com/tiran'
activity = <Date 2022-04-02.02:37:08.500> actor = 'hoodchatham' assignee = 'none' closed = True closed_date = <Date 2022-03-30.19:28:48.089> closer = 'christian.heimes' components = ['Interpreter Core'] creation = <Date 2022-03-30.11:11:40.210> creator = 'christian.heimes' dependencies =  files =  hgrepos =  issue_num = 47162 keywords = ['patch'] message_count = 7.0 messages = ['416339', '416394', '416515', '416520', '416521', '416522', '416530'] nosy_count = 3.0 nosy_names = ['christian.heimes', 'miss-islington', 'hoodchatham'] pr_nums = ['32189'] priority = 'normal' resolution = 'fixed' stage = 'resolved' status = 'closed' superseder = None type = 'compile error' url = 'https://bugs.python.org/issue47162' versions = ['Python 3.11']
The text was updated successfully, but these errors were encountered:
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.
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