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

Petr Viktorin report at bugs.python.org
Mon Sep 2 10:46:17 EDT 2019


Petr Viktorin <encukou at gmail.com> added the comment:

> What downsides do we see raising an exception?

Yeah, on second thought, that would probably be best. We still want PR #15641 as well, so the exception doesn't actually happen in practice.

Note that _PyEval_EvalCodeWithName (the main use of func_globals) already fails with an exception if globals is NULL.

> Either we remove tp_clear or somehow we have to protect all callers of the function. Technically, any field cleared from tp_cleared leaves the function in an inconsistent state

tp_clear has a purpose; it prevents memory leaks. That leaves protecting access to the cleared fields.

(But we don't need to clear func_name and func_qualname as these must be strings.)

----------

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


More information about the Python-bugs-list mailing list