[issue38006] Crash in remove() weak reference callback of weakref.WeakValueDictionary at Python exit

Neil Schemenauer report at bugs.python.org
Tue Oct 1 16:55:23 EDT 2019


Neil Schemenauer <nas-python at arctrix.com> added the comment:

Łukasz, is there some reason you removed old versions (2.7, 3.6, etc)?  The bug is present on those versions of Python and it should be trivial to backport the fix.  If those branches are maintained, I think we should fix it.

Attached is a small test program (gc_weakref_bug_demo2.py) that causes the same crash as in this bug report (SEGV inside _PyFunction_Vectorcall).  Setting things up is quite tricky and it depends on the order that things are cleared in delete_garbage().  Maybe still worth making a unit test for it?

Instead of using the 'dummy' function, you can also use types.SimpleNamespace().  Calling repr() on it after tp_clear will result in a crash or an assert failure.  Those two crashes are not needed to confirm the bug.  Just the fact that 'callback' runs is proof enough.  So, in a unit test, the callback to just set a global to indicate failure.

----------
Added file: https://bugs.python.org/file48637/gc_weakref_bug_demo2.py

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38006>
_______________________________________


More information about the Python-bugs-list mailing list