pyodide: Pyodide Crashes with JSPI Enabled on Memory Leak Test

Background

I have been seeing periodic crashes in Pyodide when JSPI is enabled that can’t be reproduced when JSPI is disabled.

The closest issue to this I found was #5597 which is listed as fixed in 0.27.7 via #5599. Running the test case from that issue shows that a crash occurs… albeit with different symptoms.

In the prior issue, high memory usage was observed (3GB+) in the webworker. In my test, memory appeared to remain constant with 0.27.7 but still crash.

With Chrome’s JSPI flag disabled, the crash does not occur.

Image


The browser error displayed is STATUS_STACK_BUFFER_OVERRUN

Edit: Added Chrome error message to make this more searchable


🐛 Bug

Running the test case from #5597 against 0.27.7 crashes after 300k iterations on Windows / Chrome with JSPI enabled. With JSPI disabled, test runs to completion.

To Reproduce

This is the same test case from #5597 modified to use 0.27.7. Crash also occurs against dev build.

minimal_bug_demo_27_7.html.txt

Expected behavior

Expect the test case to run to completion, which is does when JSPI is disabled.

Environment

Additional context

pyodide.asm.js:10 RuntimeError: null function or function signature mismatch
    at pyodide.asm.wasm:0x2a2e9f
    at pyodide.asm.wasm:0x2a75df
    at pyodide.asm.wasm:0x1c53af
    at pyodide.asm.wasm:0x1c6e57
    at pyodide.asm.wasm:0x1c4f19
    at pyodide.asm.wasm:0x1c51f1
    at pyodide.asm.wasm:0x1c526f
    at pyodide.asm.wasm:0x2a1081
    at pyodide.asm.wasm:0x2a75df
    at pyodide.asm.wasm:0x1c53af
API.fatal_error	@	pyodide.asm.js:10
callPyObjectKwargsPromising	@	pyodide.asm.js:10
await in callPyObjectKwargsPromising		
Module.callPyObjectMaybePromising	@	pyodide.asm.js:10
wrapper	@	pyodide.asm.js:10
e.port1.onmessage	@	pyodide.asm.js:10
pyodide.asm.js:10 Stack (most recent call first):
pyodide.asm.js:10   File "/lib/python312.zip/pyodide/webloop.py", line 352 in call_later
pyodide.asm.js:10   File "/lib/python312.zip/pyodide/webloop.py", line 294 in call_soon
pyodide.asm.js:10   File "/lib/python312.zip/asyncio/events.py", line 88 in _run
pyodide.asm.js:10   File "/lib/python312.zip/pyodide/webloop.py", line 340 in run_handle
pyodide.asm.js:10 Uncaught (in promise) RuntimeError: null function or function signature mismatch
    at pyodide.asm.wasm:0x2a2e9f
    at pyodide.asm.wasm:0x2a75df
    at pyodide.asm.wasm:0x1c53af
    at pyodide.asm.wasm:0x1c6e57
    at pyodide.asm.wasm:0x1c4f19
    at pyodide.asm.wasm:0x1c51f1
    at pyodide.asm.wasm:0x1c526f
    at pyodide.asm.wasm:0x2a1081
    at pyodide.asm.wasm:0x2a75df
    at pyodide.asm.wasm:0x1c53af
$_PyEval_EvalFrameDefault	@	pyodide.asm.wasm:0x2a2e9f
$func3435	@	pyodide.asm.wasm:0x2a75df
$_PyFunction_Vectorcall	@	pyodide.asm.wasm:0x1c53af
$func1217	@	pyodide.asm.wasm:0x1c6e57
$func1165	@	pyodide.asm.wasm:0x1c4f19
$_PyObject_Call	@	pyodide.asm.wasm:0x1c51f1
$PyObject_Call	@	pyodide.asm.wasm:0x1c526f
$_PyEval_EvalFrameDefault	@	pyodide.asm.wasm:0x2a1081
$func3435	@	pyodide.asm.wasm:0x2a75df
$_PyFunction_Vectorcall	@	pyodide.asm.wasm:0x1c53af
$PyObject_VectorcallMethod	@	pyodide.asm.wasm:0x1c5da8
$func5031	@	pyodide.asm.wasm:0x3484c7
$func5027	@	pyodide.asm.wasm:0x347709
$func5025	@	pyodide.asm.wasm:0x346f6c
$func5024	@	pyodide.asm.wasm:0x346f41
$func4592	@	pyodide.asm.wasm:0x328962
$_PyObject_MakeTpCall	@	pyodide.asm.wasm:0x1c47fb
$func3628	@	pyodide.asm.wasm:0x2ca6ad
$func2190	@	pyodide.asm.wasm:0x20c5f8
$func1165	@	pyodide.asm.wasm:0x1c4ee2
$_PyObject_Call	@	pyodide.asm.wasm:0x1c51f1
$PyObject_Call	@	pyodide.asm.wasm:0x1c526f
$_PyEval_EvalFrameDefault	@	pyodide.asm.wasm:0x2a1081
$func3435	@	pyodide.asm.wasm:0x2a75df
$_PyFunction_Vectorcall	@	pyodide.asm.wasm:0x1c53af
$PyObject_Vectorcall	@	pyodide.asm.wasm:0x1c5018
$_pyproxy_apply	@	pyodide.asm.wasm:0x177d9b
$_pyproxy_apply_promising	@	pyodide.asm.wasm:0x177ebd
wrapper	@	pyodide.asm.js:10
promisingApply	@	pyodide.asm.js:10
callPyObjectKwargsPromising	@	pyodide.asm.js:10
Module.callPyObjectMaybePromising	@	pyodide.asm.js:10
wrapper	@	pyodide.asm.js:10
e.port1.onmessage	@	pyodide.asm.js:10
```

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Comments: 24 (13 by maintainers)

Commits related to this issue

Most upvoted comments

For sure, yes, that test just demonstrates against browser defaults.

With JSPI enabled, all four versions fail, as shown in: https://github.com/paultiq/pyodide_testing/actions/runs/16094110319