[Bug]: JVM crash (SIGSEGV in Py_REFCNT) on numpy.frombuffer(memoryview(java.nio.ByteBuffer))
Maintainer antworten meist innerhalb von 1 Tag
@msimacek arbeitet bereits daran.
Seit 20.10.2026.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 44/100
Rechercherichtung
Start by reproducing the failure with the provided numpy.frombuffer(memoryview(buffer)) example under GraalPy, then trace how Java ByteBuffer memoryviews are exposed to C extensions and how the buffer protocol reaches NumPy. The issue does not name relevant source files or tests, so finding the responsible interop path will take codebase exploration. Done means the example returns a valid four-element array or raises a Python exception instead of crashing the JVM.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Describe the bug
Calling numpy.frombuffer on a memoryview of a Java java.nio.ByteBuffer crashes the JVM with SIGSEGV in Py_REFCNT (libpython-native.so). A Python-level error, or a working zero-copy view, would be expected.
Operating system
Linux (NixOS), kernel 6.18
CPU architecture
x86_64
GraalPy version
25.4.4 (python-language 25.4.4.1.1, embedded via Micronaut/Pyronaut)
JDK version
GraalVM CE 25.4.4.1.1 (JDK 25.0.4)
Context configuration
Embedded context built by Micronaut's GraalPyContextFactory (Pyronaut 0.1.0): allowNativeAccess(true), allowHostAccess(...), allowHostClassLookup(...), allowValueSharing(true), allowPolyglotAccess(ALL), the java posix backend, and a venv with numpy 2.4.4 from the GraalPy wheel index (numpy-2.4.4-graalpy313-graalpy253_313_native-manylinux_2_27_x86_64.whl).
Steps to reproduce
import numpy as np
from java.nio import ByteBuffer, ByteOrder
buffer = ByteBuffer.allocate(16).order(ByteOrder.LITTLE_ENDIAN)
print(np.frombuffer(memoryview(buffer), dtype="<f4")) # JVM dies here
This was run as a pytest test under pyronaut test. It crashes on every run.
Expected behavior
Either a 4-element float32 array, sharing or copying the buffer's memory, or a Python exception if host buffers can't be exported through the buffer protocol to C extensions.
Stack trace
# SIGSEGV (0xb) at pc=0x00007fff79ad2db5, pid=174452, tid=174453
# Problematic frame:
# C [libpython-native.so+0x23db5] Py_REFCNT+0x5
C [libpython-native.so+0x23db5] Py_REFCNT+0x5
j java.lang.invoke.LambdaForm$MH+0x0000000064e44c00.invoke(Ljava/lang/Object;JJJJ)J+64 [email protected]
j com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionInvoker.invokePYCFUNCTION_WITH_KEYWORDS(JJJJ)J+9
j com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionInvoker.invokePYCFUNCTION_WITH_KEYWORDS(...)
j com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionNodes$MethKeywordsRoot.readArgumentsAndInvokeExternalFunction(...)
j com.oracle.graal.python.builtins.objects.PythonAbstractObject$PExecuteNode.doExecute(...)
Additional context
Related: np.asarray(java_float_array) on a Java float[] fails with RecursionError: maximum recursion depth exceeded. As a result there is currently no efficient way to move a large Java primitive array into numpy. Our workaround is to write the data to a file from Java and np.frombuffer(f.read()) it in Python.
- Vorherrschende Sprache
- Python
- Sterne
- 1.7k
- Forks
- 163
- Ø Merge
- 8 Std. 15 Min.
- Gemergte PRs (30 T.)
- 49
Entwicklungsumgebung
Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus oracle/graalpython
-
[Bug]: `reversed()` on a dict or dict view returns the forward iterator type instead of `dict_reverse*iterator`Evtl. vergeben @jseop-lim hat das vor 2 Tagen übernommen. Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
oracle/graalpython#1226 ·
Maintainer antworten meist innerhalb von 1 Tag
-
[Bug]: `complex(real, imag)` converts `imag` before rejecting a non-number `real`Evtl. vergeben @jseop-lim hat das vor 2 Tagen übernommen. Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
oracle/graalpython#1225 ·
Maintainer antworten meist innerhalb von 1 Tag
-
[Bug]: sys.flags.debug is 1 whenever optimization is offEvtl. vergeben @hippi345 hat das vor 5 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
oracle/graalpython#1213 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
oracle/graalpython#1105 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
oracle/graalpython#1102 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in oracle/graalpython
Ähnliche Issues
-
resource-submission validation-passed
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
hesreallyhim/awesome-claude-code#3214 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
room-commons replace accepts an empty old string and silently prepends the new text to the pageOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
doobidoo/mcp-memory-service#1650 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 82/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
ml-explore/mlx-lm#2002 ·
Maintainer antworten meist innerhalb von 2 Tagen