[Bug]: GC hangs for a slotted Python subclass of a native weak-reference type
Los mantenedores suelen responder en 1 día
@fangerer ya está trabajando en esto.
Desde el 21/9/2026.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 45/100
Línea de trabajo
Start by running reproduce_runtime_gc.py with gc_probe.c using the documented graalpy command and confirm the differing Python and native weak-reference offsets and the collection timeout. Trace the reported layout and cyclic-GC handling for subclassable native weak-reference types; done means the offsets agree and gc.collect() reclaims the self-cycle within the timeout.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Describe the bug
A Python subclass with a nonempty __slots__ tuple can expose one weak-reference offset through its Python type while its native type representation exposes a different offset. If an ordinary native object field occupies the native offset, cyclic garbage collection can treat that field as the weak-reference list and fail to complete.
The standalone reproducer uses only the Python C API. It defines a heap type with an ordinary integer field before a Python reference field and weak-reference field, then creates a Python subclass with __slots__ = ("extra",). The subclass reports:
Python layout: 48 32
Native layout: (48, 24)
After assigning the ordinary Python reference field to the instance itself, gc.collect() does not return within 15 seconds.
This can affect extension classes that support both subclassing and weak references. An unreachable cycle can hang collection rather than being reclaimed.
Operating system
Linux
CPU architecture
x86_64
GraalPy version
25.3.4.1, Python 3.13.14, sys.implementation.version == 25.3.4, source revision 6bd9d25023bf713ae3dd7e83ee620c897a2c51d0
JDK version
25.0.4.1
Context configuration
No response
Steps to reproduce
Place the attached gc_probe.c and reproduce_runtime_gc.py in one directory, then run:
graalpy reproduce_runtime_gc.py graal-subclass
The script compiles the extension using the selected interpreter's headers and runs collection in a subprocess with a 15-second timeout.
Observed output:
3.13.14 (Wed Aug 19 15:15:54 UTC 2026)
[Graal, GraalVM CE, Java 25.0.4.1 (amd64)]
Python layout: 48 32
Native layout: (48, 24)
collecting
Collection did not return within 15 seconds.
The command exits with status 124.
Expected behavior
The Python-visible and native weak-reference offsets should describe the same object layout, and collection should return after reclaiming the unreachable self-cycle.
Stack trace
Additional context
No response
- Lenguaje dominante
- Python
- Estrellas
- 1.7k
- Forks
- 156
- Merge medio
- 4 h 56 min
- PR fusionados (30 d)
- 54
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de oracle/graalpython
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
oracle/graalpython#1105 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
oracle/graalpython#1102 ·
Los mantenedores suelen responder en 1 día
-
[Bug]: JVM crash (SIGSEGV in Py_REFCNT) on numpy.frombuffer(memoryview(java.nio.ByteBuffer))Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 44/100
oracle/graalpython#1198 ·
Los mantenedores suelen responder en 1 día
-
[Bug]: invalid signature of int.__new__ and missing signatures for __new__ dunders in extensionsAbiertobug
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
oracle/graalpython#1192 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 3/5 1-2 días Aptitud para principiantes 74/100
oracle/graalpython#1133 ·
Los mantenedores suelen responder en 1 día
Todos los issues de oracle/graalpython
Issues similares
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
mishraprafful/multihull#150 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
python-caldav/caldav#735 ·
Los mantenedores suelen responder en 1 día
-
bug triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
mealie-recipes/mealie#8682 ·
Los mantenedores suelen responder en 1 día
-
good first issue lane:repo
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100