python / python/cpython

Heap types implemented in C must have Py_TPFLAGS_HAVE_GC and implement tp_traverse

Abierto
#116,946 27 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

extension-modules type-bug
Lenguaje dominante
Python
Estrellas
77.2k
Forks
36k
Métricas de merge de PR
Métricas de PR pendientes

Descripción

If a heap type does not have Py_TPFLAGS_HAVE_GC or doesn't not implement tp_traverse, the garbage collector may fail to collect the type and most of its instances at Python exit. The problem is worse when sub-interpreters are involved: if a sub-interpreter exits and does not clear all of its memory, the other interpreters will continue running with these leaks.

See issue gh-87138 for the rationale.

I wrote an article on the lock type which had this bug and caused a memory leak: https://vstinner.github.io/subinterpreter-leaks.html

Linked PRs
  • gh-116947
  • gh-138290
  • gh-138327
  • gh-138328
  • gh-138331
  • gh-138333
  • gh-138427
  • gh-138428
  • gh-138334
  • gh-138340
  • gh-138341
  • gh-138582
  • gh-138807
  • gh-139073
  • gh-139474
  • gh-141268
  • gh-141448
  • gh-152310
  • gh-156034

The following PRs were directly closed because the types are immutable and empty:

  • gh-138329
  • gh-138330
  • gh-138332

The following PRs were wrongly merged so we reverted them:

  • gh-138266
  • gh-138320
  • gh-138322
  • gh-138288
  • gh-138321
  • gh-138323
  • gh-138289
  • gh-138324
  • gh-138326

PRs for reverting the above commits:

  • gh-138338
  • gh-138337

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza con issue gh-87138 y el artículo enlazado sobre el tipo de lock; después, haz un inventario de los tipos heap de C cubiertos por los PR enlazados. Se considera terminado cuando los tipos heap aplicables tienen Py_TPFLAGS_HAVE_GC y tp_traverse, y se han corregido las fugas descritas al salir del intérprete y en los subintérpretes.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
c, python
Área
backend
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

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.