gc.get_referrers() can be used to see objects before they are fully built
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 77.2k
- Forks
- 36k
- Métricas de merge de PR
- Métricas de PR pendientes
Descripción
Crash report
That the problem is occurring in the Py_INCREF macro, it looks like that the error occurs because the code is trying to increment the reference count of an object that doesnt exist.
Steps to reproduce the behavior:
1.create a sample file that contains:
import gc
def g():
marker = object()
yield marker
[tup] = [x for x in gc.get_referrers(marker) if type(x) is tuple]
print(tup)
print(tup[1])
tuple(g())
- just run without opt:
./target/python/Python-3.11.1/builded/bin/python3.11 ./target/python/founded/sig11_sync_Python3111_52.py
Error messages
stderr:
(<object object at 0x7f9e66d10160>, <NULL>, <NULL>, <NULL>, <NULL>, <NULL>, <NULL>, <NULL>, <NULL>, <NULL>)
Segmentation fault (core dumped)
gdb:
After run with synthetical sample, binary file aborted with Segfault:
Program terminated with signal SIGSEGV, Segmentation fault.
#0 Py_INCREF (op=0x0) at ./Include/object.h:502
warning: Source file is more recent than executable.
502 #ifdef Py_REF_DEBUG
Expected behavior
No assertion failed.
Additional context
For solution this problem added additional checking to ensure that the op argument is not a null pointer before trying to increment its reference count.
if (op == NULL) {
return;
}
(also added in a patch)
Environment
- Tested on: Python 3.11.1
- Operating system and architecture: Centos-based system (RED OS release MUROM (7.3.2)) ; 5.15.78-2.el7.3.x86_64
Linked PRs
- gh-101856
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.
Línea de trabajo
Reproduce el problema con el ejemplo de Python usando gc.get_referrers() y tuple(g()), y luego inspecciona Include/object.h en la ubicación de Py_INCREF indicada en el informe. Compara las entradas NULL observadas y el segmentation fault con el PR vinculado gh-101856; se considera terminado cuando el reproductor ya no expone entradas de tupla no válidas ni provoca fallos.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- c, python
- Área
- compilers
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 25/100