3.13.2: cast in Py_XDECREF causes runtime failures with immortal objects
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 77.2k
- Fork
- 35.9k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
Bug report
Bug description:
In Python 3.13.2 I use
Py_XDECREF(PyObject *op)
It is called at the end of a function-call to load an image (cv2.imread) which fails, resulting in a None value (not NULL!). For Python 3.9 Py_XDECREF works just fine, without crash. For Python 3.13.2 the program, compiled with VS2022 (64 Bit), raises a "Run-Time Check Failure #1 - A cast to a smaller data type has caused a loss of data." and my application crashes ("/RTC1 = Basic Runtime Checks enabled").
I followed up the calls:
Py_DECREF
_Py_IsImmortal
#elif SIZEOF_VOID_P > 4
_Py_CAST(PY_INT32_T, op->ob_refcnt) <-- crash
The value is
op->ob_refcnt == 0x0000000100000000
To fix this problem, I propose, that the type cast to 32 bit should be changed to
_Py_CAST(PY_INT32_T, op->ob_refcnt & 0xFFFFFFFF)
CPython versions tested on:
3.13
Operating systems tested on:
Windows
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.
Direzione di ricerca
Partite dal percorso di chiamata di Py_XDECREF/Py_DECREF e _Py_IsImmortal, riproducendo il fallimento di Windows VS2022 /RTC1 con il conteggio dei riferimenti immortal segnalato. Confrontate il comportamento del cast con il masking proposto, quindi verificate che il fallimento sia risolto usando i test CPython pertinenti; l’issue non indica alcun file sorgente o test specifico.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- c, python
- Ambito
- backend, operating-systems
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100