[issue25769] Crash due to using weakref referent without acquiring a strong reference

Armin Rigo report at bugs.python.org
Mon Nov 30 05:49:24 EST 2015


Armin Rigo added the comment:

PyWeakref_GET_OBJECT() is inherently dangerous: the weakref might go away not only the next time the GIL is released, but also the next time the code does any seemingly unrelated Py_DECREF() (which might decref the object into inexistence) or memory allocation (which might trigger the GC).

I'd suggest adding the comment above in the docs and reviewing all usages inside CPython's code base.

----------
nosy: +arigo

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25769>
_______________________________________


More information about the Python-bugs-list mailing list