[Bug]: GC hangs for a slotted Python subclass of a native weak-reference type
@fangerer ci sta già lavorando.
Dal 21/9/2026.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 45/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- Python
- Stelle
- 1.6k
- Fork
- 155
- Merge medio
- 8h 20m
- PR unite (30g)
- 43
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di oracle/graalpython
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
oracle/graalpython#1105 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
oracle/graalpython#1102 ·
-
bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 74/100
oracle/graalpython#1133 ·
-
bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
oracle/graalpython#1112 ·
-
bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
oracle/graalpython#1111 ·
Tutte le issue di oracle/graalpython
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
stephrobert/dsoxlab#238 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
sublimehq/package_control#1780 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
nwg-piotr/nwg-displays#145 ·