-
-
Notifications
You must be signed in to change notification settings - Fork 30.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CPython should not assume that pthread_self returns the same value in fork parent and child #126688
Comments
colesbury
added
type-bug
An unexpected behavior, bug, or error
3.13
bugs and security fixes
3.14
new features, bugs and security fixes
labels
Nov 11, 2024
colesbury
added a commit
to colesbury/cpython
that referenced
this issue
Nov 11, 2024
The PyMutex implementation supports unlocking after fork because we clear the list of watiers in parking_lot.c. This doesn't work as well for _PyRecursiveMutex because on some systems, such as SerenityOS, the thread id is not preserved across fork().
colesbury
added a commit
to colesbury/cpython
that referenced
this issue
Nov 11, 2024
The PyMutex implementation supports unlocking after fork because we clear the list of watiers in parking_lot.c. This doesn't work as well for _PyRecursiveMutex because on some systems, such as SerenityOS, the thread id is not preserved across fork().
colesbury
added a commit
to colesbury/cpython
that referenced
this issue
Nov 11, 2024
colesbury
added a commit
that referenced
this issue
Nov 12, 2024
The PyMutex implementation supports unlocking after fork because we clear the list of waiters in parking_lot.c. This doesn't work as well for _PyRecursiveMutex because on some systems, such as SerenityOS, the thread id is not preserved across fork().
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this issue
Nov 12, 2024
The PyMutex implementation supports unlocking after fork because we clear the list of waiters in parking_lot.c. This doesn't work as well for _PyRecursiveMutex because on some systems, such as SerenityOS, the thread id is not preserved across fork(). (cherry picked from commit 5610860) Co-authored-by: Sam Gross <colesbury@gmail.com>
colesbury
added a commit
that referenced
this issue
Nov 12, 2024
The PyMutex implementation supports unlocking after fork because we clear the list of waiters in parking_lot.c. This doesn't work as well for _PyRecursiveMutex because on some systems, such as SerenityOS, the thread id is not preserved across fork(). (cherry picked from commit 5610860) Co-authored-by: Sam Gross <colesbury@gmail.com>
I think this can be closed now. |
There may be other code that makes the same assumption about the thread ID. For example, in Lines 655 to 658 in 09c240f
This would break only on debug builds (or at least I'm guessing there are other places too. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Summarized from SerenityOS/serenity#25263 by request of @colesbury:
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
Linked PRs
The text was updated successfully, but these errors were encountered: