pyodide: Memory access out of bounds when creating pandas dataframe

Description

Uncaught RuntimeError: memory access out of bounds when creating pandas dataframe, with numpy.arange or dictionaries

Live Demo

https://codepen.io/dmondev/pen/gOgBWEp.

Each block in this codepen tests a pyodide usage scenario. Errors are displayed along with the python code executed.

This codepen uses a web worker with inline Blob to execute the python code.

Versions

Chrome Version 90.0.4430.72 (Official Build) (64-bit) Windows 10 1909 build 18363.1440

Error

Uncaught RuntimeError: memory access out of bounds
    at __static_1 (<anonymous>:wasm-function[174]:0x17748)
    at byn$fpcast-emu$__static_1 (<anonymous>:wasm-function[506]:0x87748)
    at __static_2 (<anonymous>:wasm-function[175]:0x17eca)
    at __static_199 (<anonymous>:wasm-function[339]:0x538d5)
    at byn$fpcast-emu$__static_199 (<anonymous>:wasm-function[704]:0x881f7)
    at __static_254 (https://cdn.jsdelivr.net/pyodide/dev/full/pyodide.asm.wasm:wasm-function[901]:0x1d3efc)
    at byn$fpcast-emu$__static_254 (https://cdn.jsdelivr.net/pyodide/dev/full/pyodide.asm.wasm:wasm-function[21696]:0x7bc708)
    at _PyObject_GenericGetAttrWithDict (https://cdn.jsdelivr.net/pyodide/dev/full/pyodide.asm.wasm:wasm-function[1713]:0x218614)
    at PyObject_GenericGetAttr (https://cdn.jsdelivr.net/pyodide/dev/full/pyodide.asm.wasm:wasm-function[1712]:0x2183c9)
    at byn$fpcast-emu$PyObject_GenericGetAttr (https://cdn.jsdelivr.net/pyodide/dev/full/pyodide.asm.wasm:wasm-function[14359]:0x7a2290)

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Comments: 15 (13 by maintainers)

Most upvoted comments

Just to confirm, Google already released v91 as stable, and I’m no longer able to reproduce the bug from the codepen above (with 0.17.0).

@hoodmane Just out of curiosity, do you know what causes this Schroedinger-bug behavior?

It seems to be a mistake deep inside of the optimizing JIT of Chrome. We asked the Chrome devs and they aren’t sure either:

I think what is going on is that this code generates an erroneous effect/control chains in the Turbofan graph. This is because some instance fields are created and cached with their current effect and control inputs, but later used in different places, where these inputs might not be valid. It is not clear to me how exactly this results in the actual bug. In any case, this code has been streamlined since and this issue should be fixed. As expected, we cannot reproduce it in later versions.

From our chrome bug report: https://bugs.chromium.org/p/chromium/issues/detail?id=1200031

Thank you for the explanation! This definitely comes on my top 10 list of bugs that I could not have imagined.

I face the same issue when I run the code snippet below:

import pandas
import plotly.express as px

df = px.data.iris()
fig = px.scatter(
df, x="sepal_width", y="sepal_length",
color="species")

fig

await pyodide.loadPackage(['numpy', 'pandas', 'plotly']) hasn’t solved this issue

For this codepen to work on the latest dev version, you need to add await pyodide.loadPackage(['numpy', 'pandas']); after await loadPyodide({ indexURL });.