[pypy-issue] Issue #2287: __del__ on subclasses of some built-in types can crash (pypy/pypy)

Armin Rigo issues-reply at bitbucket.org
Sun May 1 05:00:30 EDT 2016

New issue 2287: __del__ on subclasses of some built-in types can crash

Armin Rigo:

This crashes PyPy:

import array, gc

class X(array.array):
    def __del__(self):
        global saved
        saved = self

while True:
    X('i', [2,3,4])
    saved[0] += 1

The issue is that when we have both an app-level and an interp-level ``__del__``, and the interp-level one is supposed to be a lightweight finalizer, we call the interp-level one always after calling the app-level one.  But the lightweight finalizer of classes like W_Array is written with this basic property in mind: after it is called, there should be no more references to the object.

A proper fix is involved; I suppose we should give a try again to the ``gc-del`` branch.

More information about the pypy-issue mailing list