[Bug]: JVM crash (SIGSEGV in Py_REFCNT) on numpy.frombuffer(memoryview(java.nio.ByteBuffer))
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 44/100
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- Python
- Estrelas
- 1.7k
- Forks
- 158
- Merge médio
- 8h 15min
- PRs com merge (30d)
- 49
Preparar o ambiente
Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de oracle/graalpython
-
[Bug]: `reversed()` on a dict or dict view returns the forward iterator type instead of `dict_reverse*iterator`Talvez já em andamento @jseop-lim assumiu há 2 dias. Abertabug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
oracle/graalpython#1226 ·
Mantenedores costumam responder em até 1 dia
-
[Bug]: `complex(real, imag)` converts `imag` before rejecting a non-number `real`Talvez já em andamento @jseop-lim assumiu há 2 dias. Abertabug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
oracle/graalpython#1225 ·
Mantenedores costumam responder em até 1 dia
-
[Bug]: sys.flags.debug is 1 whenever optimization is offTalvez já em andamento @hippi345 assumiu há 5 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
oracle/graalpython#1213 ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
oracle/graalpython#1105 ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
oracle/graalpython#1102 ·
Mantenedores costumam responder em até 1 dia
Todas as issues de oracle/graalpython
Issues semelhantes
-
bug good first issue
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
yunaremaia/proto-drift#22 ·
-
bug good first issue
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
yunaremaia/memwatch#96 ·
-
bug good first issue
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 91/100
yunaremaia/ci-gate-watch#34 ·
-
bug good first issue
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
yunaremaia/agent-capability-attestation#64 ·
Mantenedores costumam responder em até 1 dia
-
bug good first issue
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 86/100
yunaremaia/agent-call-graph#43 ·
Mantenedores costumam responder em até 1 dia