This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author David.Edelsohn
Recipients David.Edelsohn, Michael.Felt, shihai1991, vstinner
Date 2021-05-24.20:16:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1621887401.22.0.0380670631889.issue40092@roundup.psfhosted.org>
In-reply-to
Content
It seems that PyOS_AfterFork_Child() needs to do something like

PyThreadState *tstate = PyThreadState_Get();
PyObject *wr = _PyObject_CAST(tstate->on_delete_data);
PyObject *obj = PyWeakref_GET_OBJECT(wr);
lockobject *lock;
if (obj != Py_None) {
    lock = (lockobject *) obj;
    if (lock->locked) {
        /* Leak memory on purpose. */
        lock->locked = 0;
    }
}

before the call to _PyEval_ReInitThreads.

Maybe encapsulate that as PyThread_ReInitThreads().

The locks in the threads in the child need to be cleared before _PyThreadState_DeleteExcept() so that Python does not try to release the locks in the child.
History
Date User Action Args
2021-05-24 20:16:41David.Edelsohnsetrecipients: + David.Edelsohn, vstinner, Michael.Felt, shihai1991
2021-05-24 20:16:41David.Edelsohnsetmessageid: <1621887401.22.0.0380670631889.issue40092@roundup.psfhosted.org>
2021-05-24 20:16:41David.Edelsohnlinkissue40092 messages
2021-05-24 20:16:41David.Edelsohncreate