[Bug]: JVM crash (SIGSEGV in Py_REFCNT) on numpy.frombuffer(memoryview(java.nio.ByteBuffer))
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 44/100
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- Python
- Étoiles
- 1.7k
- Forks
- 156
- Merge moyen
- 4 h 56 min
- PR mergées (30 j)
- 54
Préparer son environnement
Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de oracle/graalpython
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
oracle/graalpython#1105 ·
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
oracle/graalpython#1102 ·
Les mainteneurs répondent en général sous 1 jour
-
[Bug]: invalid signature of int.__new__ and missing signatures for __new__ dunders in extensionsOuvertebug
Difficulté 4/5 3-5 jours Accessibilité débutants 48/100
oracle/graalpython#1192 ·
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 3/5 1-2 jours Accessibilité débutants 74/100
oracle/graalpython#1133 ·
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 3/5 1-2 jours Accessibilité débutants 68/100
oracle/graalpython#1112 ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de oracle/graalpython
Issues similaires
-
docs(types): update the collection binding note now that typed collections shipped in pycubrid 1.9.0Ouvertedocumentation priority: low size: S
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
cubrid-lab/sqlalchemy-cubrid#768 ·
Les mainteneurs répondent en général sous 1 jour
-
--csv-bom was never wired up: PR #850 added an unused helper parameter, so #846 is not fixedOuvertebug help wanted
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
Les mainteneurs répondent en général sous 1 jour
-
Broken link in index.rstOuvertedocumentation
Difficulté 1/5 Moins d'une heure Accessibilité débutants 65/100
ansys/pydpf-core#3547 ·
Les mainteneurs répondent en général sous 1 jour
-
core
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
vectorize-io/hindsight#5457 ·
Les mainteneurs répondent en général sous 1 jour
-
[Bug]: LangChain drops OpenAI Responses text blocks from session recordingPeut-être pris @ktz03 l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
volcengine/OpenViking#5806 ·
Les mainteneurs répondent en général sous 1 jour