[issue17703] Trash can mechanism segfault during interpreter finalization in Python 2.7.4

Marc-Andre Lemburg report at bugs.python.org
Fri Apr 12 15:45:37 CEST 2013


Marc-Andre Lemburg added the comment:

After a closer look at recent checkins, I found this checking for the trash can mechanism: 5a2ef447b80d (ticket #13992).

This appears to be the cause:

    1.20  #define Py_TRASHCAN_SAFE_BEGIN(op) \
    1.21 -    if (_PyTrash_delete_nesting < PyTrash_UNWIND_LEVEL) { \
    1.22 -        ++_PyTrash_delete_nesting;
    1.23 -        /* The body of the deallocator is here. */
    1.24 +    do { \
    1.25 +        PyThreadState *_tstate = PyThreadState_GET(); \
    1.26 +        if (_tstate->trash_delete_nesting < PyTrash_UNWIND_LEVEL) { \
    1.27 +            ++_tstate->trash_delete_nesting;
    1.28 +            /* The body of the deallocator is here. */

At the time the Py_AtExit functions are called, the thread state
is NULL, so the if (_tstate->...) segfaults.

----------

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


More information about the Python-bugs-list mailing list