Uh oh!
There was an error while loading. Please reload this page.
gh-109746: Make _thread.start_new_thread delete state of new thread on its startup failure - #109761
gh-109746: Make _thread.start_new_thread delete state of new thread on its startup failure#109761serhiy-storchaka merged 9 commits into
_thread.start_new_thread delete state of new thread on its startup failure#109761Conversation
If Python fails to start newly created thread due to failure of underlying PyThread_start_new_thread() call, its state should be removed from interpreter' thread states list to avoid its double cleanup * make 'PyThreadState_Delete' accept unbound thread state * in 'thread_PyThread_start_new_thread', delete state of new thread from interpreter if 'PyThread_start_new_thread' call fails
_thread.start_new_thread delete state of new thread on its startup failure_thread.start_new_thread delete state of new thread on its startup failureUh oh!
There was an error while loading. Please reload this page.
serhiy-storchaka
commented
Jan 18, 2024
The test did not fail on non-patched code, failed on Windows, and hanged on macOS. I rewrote it. According to a comment in a similar test, |
serhiy-storchaka
commented
Jan 18, 2024
!buildbot bsd |
bedevere-bot
commented
Jan 18, 2024
🤖 New build scheduled with the buildbot fleet by @serhiy-storchaka for commit 1f3ecd9 🤖 The command will test the builders whose names match following regular expression: The builders matched are:
|
devdanzin
commented
Nov 22, 2024
Applying a version of the fix in this PR solves an issue I had where all processes with large thread counts would abort at finalization (particularly annoying when you're trying to fuzz CPython). |
serhiy-storchaka
commented
Nov 22, 2024
!buildbot bsd |
bedevere-bot
commented
Nov 22, 2024
🤖 New build scheduled with the buildbot fleet by @serhiy-storchaka for commit 185d5a6 🤖 The command will test the builders whose names match following regular expression: The builders matched are:
|
serhiy-storchaka
commented
Nov 22, 2024
!buildbot bsd |
bedevere-bot
commented
Nov 22, 2024
🤖 New build scheduled with the buildbot fleet by @serhiy-storchaka for commit 55a8237 🤖 The command will test the builders whose names match following regular expression: The builders matched are:
|
Thanks @chgnrdv for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13. |
Sorry, @chgnrdv and @serhiy-storchaka, I could not cleanly backport this to |
… new thread on its startup failure (pythonGH-109761) If Python fails to start newly created thread due to failure of underlying PyThread_start_new_thread() call, its state should be removed from interpreter' thread states list to avoid its double cleanup. (cherry picked from commit ca3ea9a) Co-authored-by: Radislav Chugunov <52372310+chgnrdv@users.noreply.github.com> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
GH-127171 is a backport of this pull request to the 3.13 branch. |
… new thread on its startup failure (pythonGH-109761) If Python fails to start newly created thread due to failure of underlying PyThread_start_new_thread() call, its state should be removed from interpreter' thread states list to avoid its double cleanup. (cherry picked from commit ca3ea9a) Co-authored-by: Radislav Chugunov <52372310+chgnrdv@users.noreply.github.com> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
GH-127173 is a backport of this pull request to the 3.12 branch. |
…hread on its startup failure (GH-109761) (GH-127171) If Python fails to start newly created thread due to failure of underlying PyThread_start_new_thread() call, its state should be removed from interpreter' thread states list to avoid its double cleanup. (cherry picked from commit ca3ea9a) Co-authored-by: Radislav Chugunov <52372310+chgnrdv@users.noreply.github.com>
…hread on its startup failure (GH-109761) (GH-127173) If Python fails to start newly created thread due to failure of underlying PyThread_start_new_thread() call, its state should be removed from interpreter' thread states list to avoid its double cleanup. (cherry picked from commit ca3ea9a) Co-authored-by: Radislav Chugunov <52372310+chgnrdv@users.noreply.github.com>
vstinner
commented
Nov 26, 2024
The test is unstable on macOS and FreeBSD: it fails randomly. Examples:
Example of failure on FreeBSD: |
vstinner
commented
Nov 26, 2024
On Linux, RLIMIT_NPROC is the maximum number of threads. On FreeBSD, RLIMIT_NPROC is the maximum number of processes. |
vstinner
commented
Nov 26, 2024
I suggest to make the test specific to Linux, or use another approach than RLIMIT_NPROC. |
serhiy-storchaka
commented
Nov 26, 2024
Ah, there is a race condition here. Should be fixed by #127299. |
…read on its startup failure (pythonGH-109761) If Python fails to start newly created thread due to failure of underlying PyThread_start_new_thread() call, its state should be removed from interpreter' thread states list to avoid its double cleanup. Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Fixes#109746.
If Python fails to start newly created thread due to failure of underlying PyThread_start_new_thread() call, its state should be removed from interpreter' thread states list to avoid its double cleanup.
PyThreadState_Deleteaccept unbound thread statethread_PyThread_start_new_thread, delete state of new thread from interpreter ifPyThread_start_new_threadcall fails