You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CPython should not assume that pthread_self returns the same value in fork parent and child #126688
It seems that at least Python 3.13 relies on pthread_self returning the same value in both the parent and the child process. PyThread_get_thread_ident_ex
POSIX doesn't seem to mention if the value returned by pthread_self should be inherited by the child process. pthread_self fork
(It is the case on Linux, Hurd, FreeBSD, OpenBSD, Cygwin. It isn't on SerenityOS, and also not on Solaris 9/HP-UX 11 per https://bugs.python.org/issue7242.
It looks like the code add broke things is from this commit e21057b added in #118523 as part of #117657
Activity
pythongh-126688: Reinit import lock after fork
pythongh-126688: Reinit import lock after fork
Merge branch 'main' into pythongh-126688-import-lock
gh-126688: Reinit import lock after fork (#126692)
pythongh-126688: Reinit import lock after fork (pythonGH-126692)
[3.13] gh-126688: Reinit import lock after fork (GH-126692) (GH-126765)
oskar-skog commentedon Nov 12, 2024
I think this can be closed now.
ericsnowcurrently commentedon Nov 21, 2024
There may be other code that makes the same assumption about the thread ID. For example, in
PyOS_AfterFork_Child():cpython/Modules/posixmodule.c
Lines 655 to 658 in 09c240f
This would break only on debug builds (or at least
!defined(NDEBUG)).I'm guessing there are other places too.
pythongh-126688: Reinit import lock after fork (python#126692)
pythongh-126688: Reinit import lock after fork (python#126692)