René's URL Explorer Experiment


Title: Free-threaded CPython: concurrent new_threadstate() / PyGILState_Ensure() from N≥~8 OS threads deadlocks in _PyEval_StopTheWorld · Issue #157666 · python/cpython · GitHub

Open Graph Title: Free-threaded CPython: concurrent new_threadstate() / PyGILState_Ensure() from N≥~8 OS threads deadlocks in _PyEval_StopTheWorld · Issue #157666 · python/cpython

X Title: Free-threaded CPython: concurrent new_threadstate() / PyGILState_Ensure() from N≥~8 OS threads deadlocks in _PyEval_StopTheWorld · Issue #157666 · python/cpython

Description: Bug report Bug description: In Python/pystate.c, new_threadstate() → _Py_qsbr_reserve() → (when QSBR freelist is empty) _PyEval_StopTheWorld(interp) (see qsbr.c: _Py_qsbr_reserve, and 3.14.0's pystate.c STW path). When ≥~8 OS threads ent...

Open Graph Description: Bug report Bug description: In Python/pystate.c, new_threadstate() → _Py_qsbr_reserve() → (when QSBR freelist is empty) _PyEval_StopTheWorld(interp) (see qsbr.c: _Py_qsbr_reserve, and 3.14.0's pyst...

X Description: Bug report Bug description: In Python/pystate.c, new_threadstate() → _Py_qsbr_reserve() → (when QSBR freelist is empty) _PyEval_StopTheWorld(interp) (see qsbr.c: _Py_qsbr_reserve, and 3.14.0's ...

Opengraph URL: https://github.com/python/cpython/issues/157666

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Free-threaded CPython: concurrent new_threadstate() / PyGILState_Ensure() from N≥~8 OS threads deadlocks in _PyEval_StopTheWorld","articleBody":"# Bug report\n\n### Bug description:\n\nIn Python/pystate.c, new_threadstate() → _Py_qsbr_reserve() → (when QSBR freelist is empty) _PyEval_StopTheWorld(interp) (see qsbr.c: _Py_qsbr_reserve, and 3.14.0's pystate.c STW path). When ≥~8 OS threads enter PyGILState_Ensure simultaneously from fresh threads, the first one to hit an empty QSBR freelist requests an STW; the other ≥7 threads are concurrently in (or about to enter) tstate_wait_attach/tstate_try_attach/new_threadstate. They cannot proceed because the STW is not yet complete, and the STW requester cannot complete because the attach path is blocked — a circular stall (futex_do_wait, ~0 CPU).\n\nDistinct from #151518 (and not fixed by the first pull request there).\n\nShort reproducer:\n\n```c\n/* N pthreads, each: PyGILState_Ensure -> loop of 5,000x PyEval_SaveThread/RestoreThread -> PyGILState_Release.\n   Trigger: >=8 threads (deterministic at 8, 12, 16, 20 on every version tested);\n   6 and below: passes. \n\ncc -O2 -pthread -o repro repro_ft.c \\\n   -I/tmp/\u003cprefix>/include/python3.1Xt \\\n   /tmp/\u003cprefix>/lib/libpython3.1Xt.a -lpthread -lm -lutil -ldl\n\ntimeout 45 ./repro 8   # -> \"launched worker 8\" then HANG (exit 124)\n*/\n#include \u003cPython.h>\n#include \u003cpthread.h>\n#include \u003cstdio.h>\n#include \u003cstdlib.h>\n\nstatic volatile long long counter = 0;\nstatic volatile int g_stop = 0;\nstatic int g_iters = 5000;\nstatic int g_mode = 1;  /* 1=churn, 0=once */\n\nstatic void *worker(void *arg) {\n    PyGILState_STATE st = PyGILState_Ensure();\n    long long n = 0;\n    for (long long i = 0; i \u003c g_iters && !g_stop; i++) {\n        if (g_mode == 0) { /* once: already ensured once, loop is Save/Restore only */\n        }\n        PyThreadState *ts = PyEval_SaveThread();\n        for (volatile int k = 0; k \u003c 100; k++) {}\n        PyEval_RestoreThread(ts);\n        n++;\n    }\n    PyGILState_Release(st);\n    __sync_fetch_and_add(&counter, n);\n    return NULL;\n}\n\nint main(int argc, char **argv) {\n    int n = argc > 1 ? atoi(argv[1]) : 8;\n    g_mode = argc > 2 && !strcmp(argv[2], \"once\") ? 0 : 1;\n    g_iters = argc > 3 ? (int)atol(argv[3]) : 5000;\n    Py_Initialize();\n    fprintf(stderr, \"Py_VERSION=%s\\n\", Py_GetVersion());\n    pthread_t *t = malloc(sizeof(pthread_t) * n);\n    for (int i = 0; i \u003c n; i++) { pthread_create(&t[i], NULL, worker, NULL); fprintf(stderr, \"launched worker %d\\n\", i); }\n    for (int i = 0; i \u003c n; i++) pthread_join(t[i], NULL);\n    fprintf(stderr, \"ALL WORKERS COMPLETED (PASS) counter=%lld\\n\", counter);\n    Py_Finalize();\n    return 0;\n}\n```\n\nEnvironment / repro notes\n- Tested on Ryzen 7700X (8 physical cores, 16 logical) (my B200 is undergoing repairs, honestly)\n- Ubuntu 25.04\n- Linux kernel 7.2.2\n- GNU C (cc) 14.2.0\n- GIL-disabled builds only (Py_GIL_DISABLED=1); GIL-enabled builds do not exercise the Py_GILState_* STW path in this code.\n- LD_PRELOAD none; no ASAN/UBSAN at build time.\n\nResults\n| Threads | 3.14.0 (installed, FT) | 3.15.0rc2 (unpatched, FT) | 3.15.0rc2 + PR #152826 (FT) |\n|---------|------------------------|---------------------------|-----------------------------|\n| 4       | PASS                   | PASS                      | PASS                        |\n| 6       | PASS                   | PASS                      | PASS                        |\n| 8       | HANG (exit 124)        | HANG (exit 124)           | HANG (exit 124)             |\n| 12      | HANG (exit 124)        | HANG (exit 124)           | HANG (exit 124)             |\n| 20      | HANG (exit 124)        | —                         | —                           |\n\nCheckbox (per CPython \"Reporting bugs\" convention)\n- [x] I can reproduce this on the current stable (3.14.0) and current development/RC (3.15.0rc2) free-threading builds.\n- [x] I built from source (3.15.0rc2) and I can provide the exact --disable-gil build recipe.\n- [ ] I can reproduce this on the Windows or macOS free-threading builds — not tested (Linux x86_64 only so far).\n- [ ] I can reproduce it on Python \u003c 3.14 — not tested (free-threading is 3.13+/3.14+/3.15+; I expect the same stall on 3.13 free-threading but have not measured it).\n\n\n\n\n### CPython versions tested on:\n\n3.15\n\n### Operating systems tested on:\n\nLinux","author":{"url":"https://github.com/CypherGrue","@type":"Person","name":"CypherGrue"},"datePublished":"2026-09-17T08:52:38Z","url":"https://github.com/python/cpython/issues/157666"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:358ebfe3-bea1-cc8a-d582-c00b1846a813
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE164:F7C4C:344245B:45F6A2C:6B020950
html-safe-nonced3e4422f01f0df87f92132dc441a12707c7d0f0eabf0f03378e3269d954c2674
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMTY0OkY3QzRDOjM0NDI0NUI6NDVGNkEyQzo2QjAyMDk1MCIsInZpc2l0b3JfaWQiOiI3MDg2OTYzMTE3NDE5NDIwOTYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac742653a76b1db5502b93664ce27e6a867ba16ee1307b72a216cbd33f387d7036
hovercard-subject-tagissue:5485153559
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/157666/issue_layout
twitter:imagehttps://opengraph.githubassets.com/a525f5f93e49738a41da26cb8e3700e74b0685a6d78ab17c1a5d63d078ff4911/python/cpython/issues/157666
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/a525f5f93e49738a41da26cb8e3700e74b0685a6d78ab17c1a5d63d078ff4911/python/cpython/issues/157666
og:image:altBug report Bug description: In Python/pystate.c, new_threadstate() → _Py_qsbr_reserve() → (when QSBR freelist is empty) _PyEval_StopTheWorld(interp) (see qsbr.c: _Py_qsbr_reserve, and 3.14.0's pyst...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameCypherGrue
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
turbo-cache-controlno-preview
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release423dbb54c5e7bfecc838eb387c1435eb3d0e760d
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/cpython/issues/157666#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F157666
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F157666
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/157666
Reloadhttps://github.com/python/cpython/issues/157666
Reloadhttps://github.com/python/cpython/issues/157666
pythonhttps://github.com/python
cpythonhttps://github.com/python/cpython
Codehttps://github.com/python/cpython
Issues5k+ (5k+)https://github.com/python/cpython/issues
Pull requests2.4k (2.4k)https://github.com/python/cpython/pulls
Actionshttps://github.com/python/cpython/actions
Projectshttps://github.com/python/cpython/projects
Security and qualityhttps://github.com/python/cpython/security
Insightshttps://github.com/python/cpython/insights
https://github.com/python/cpython
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/157666
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/157666
Free-threaded CPython: concurrent new_threadstate() / PyGILState_Ensure() from N≥~8 OS threads deadlocks in _PyEval_StopTheWorldhttps://github.com/python/cpython/issues/157666#top
pendingThe issue will be closed if no feedback is providedhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22pending%22
topic-free-threadinghttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-free-threading%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com/CypherGrue
CypherGruehttps://github.com/CypherGrue
on Sep 17, 2026https://github.com/python/cpython/issues/157666#issue-5485153559
#151518https://github.com/python/cpython/issues/151518
#152826https://github.com/python/cpython/pull/152826
CypherGruehttps://github.com/CypherGrue
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
on Sep 17, 2026https://github.com/python/cpython/issues/157666#event-31306233206
https://github.com/CypherGrue
CypherGruehttps://github.com/CypherGrue
on Sep 17, 2026https://github.com/python/cpython/issues/157666#issuecomment-5711913744
aiskhttps://github.com/aisk
topic-free-threadinghttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-free-threading%22
on Sep 17, 2026https://github.com/python/cpython/issues/157666#event-31334443128
https://github.com/ngoldbaum
ngoldbaumhttps://github.com/ngoldbaum
on Sep 17, 2026https://github.com/python/cpython/issues/157666#issuecomment-5719538924
https://github.com/CypherGrue
CypherGruehttps://github.com/CypherGrue
on Sep 17, 2026https://github.com/python/cpython/issues/157666#issuecomment-5720910672
https://github.com/colesbury
colesburyhttps://github.com/colesbury
on Sep 17, 2026https://github.com/python/cpython/issues/157666#issuecomment-5720957204
…https://github.com/python/cpython/issues/157666
#157666 (comment)https://github.com/python/cpython/issues/157666#issuecomment-5720910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QYLTL5WGCYTFNSWHG5LCNJSWG5C7OR4XAZNMJFZXG5LFINXW23LFNZ2KO5DSNFTWOZLSUZRXEZLBORSQ
https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675
https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithubhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub
https://github.com/colesbury
colesburyhttps://github.com/colesbury
on Sep 18, 2026https://github.com/python/cpython/issues/157666#issuecomment-5730174345
colesburyhttps://github.com/colesbury
pendingThe issue will be closed if no feedback is providedhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22pending%22
on Sep 18, 2026https://github.com/python/cpython/issues/157666#event-31390107600
https://github.com/colesbury
colesburyhttps://github.com/colesbury
on Sep 18, 2026https://github.com/python/cpython/issues/157666#issuecomment-5730234364
https://github.com/ngoldbaum
ngoldbaumhttps://github.com/ngoldbaum
on Sep 18, 2026https://github.com/python/cpython/issues/157666#issuecomment-5730313115
https://github.com/CypherGrue
CypherGruehttps://github.com/CypherGrue
on Sep 18, 2026https://github.com/python/cpython/issues/157666#issuecomment-5734968497
CypherGruehttps://github.com/CypherGrue
completedhttps://github.com/python/cpython/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Sep 18, 2026https://github.com/python/cpython/issues/157666#event-31412454212
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/157666
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/157666
pendingThe issue will be closed if no feedback is providedhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22pending%22
topic-free-threadinghttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-free-threading%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.