[issue22653] Crash in insertdict

Antoine Pitrou report at bugs.python.org
Thu Oct 16 14:45:38 CEST 2014


Antoine Pitrou added the comment:

Looking down into the insertdict frame:

(gdb) p key
$14 = 'f'
(gdb) p old_value
$15 = <unknown at remote 0x7f27e766e678>
(gdb) p *ep
$16 = {me_hash = -3761688987579986997, me_key = 0x0, me_value = 0x0}


So this seems to have hit the following line in insertdict():

    if (old_value != NULL) {
        assert(ep->me_key != NULL && ep->me_key != dummy);
        *value_addr = value;
--->    Py_DECREF(old_value); /* which **CAN** re-enter */
    }

And it *has* reentered because the ResourceWarning inserted the __warningregistry__ attribute into the __main__ dict.

Note the reentrancy looks safe: the dict should be in a stable state at this point (?). But the assert at the end of insertdict assumes the dict hasn't mutated... Why?

----------

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


More information about the Python-bugs-list mailing list