René's URL Explorer Experiment


Title: Free-threaded build: reading a sys._current_frames() frame is a use-after-free · Issue #152355 · python/cpython · GitHub

Open Graph Title: Free-threaded build: reading a sys._current_frames() frame is a use-after-free · Issue #152355 · python/cpython

X Title: Free-threaded build: reading a sys._current_frames() frame is a use-after-free · Issue #152355 · python/cpython

Description: Crash report What happened? frame_read_sync.patch Free-threaded build: reading a sys._current_frames() frame is a use-after-free Affects: free-threaded build only (--disable-gil; python3.13t, PYTHON_GIL=0). The default (GIL) build is saf...

Open Graph Description: Crash report What happened? frame_read_sync.patch Free-threaded build: reading a sys._current_frames() frame is a use-after-free Affects: free-threaded build only (--disable-gil; python3.13t, PYTHO...

X Description: Crash report What happened? frame_read_sync.patch Free-threaded build: reading a sys._current_frames() frame is a use-after-free Affects: free-threaded build only (--disable-gil; python3.13t, PYTHO...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Free-threaded build: reading a sys._current_frames() frame is a use-after-free","articleBody":"# Crash report\n\n### What happened?\n\n[frame_read_sync.patch](https://github.com/user-attachments/files/29399904/frame_read_sync.patch)\n\n# Free-threaded build: reading a `sys._current_frames()` frame is a use-after-free\n\n**Affects:** free-threaded build only (`--disable-gil`; `python3.13t`, `PYTHON_GIL=0`). The default (GIL) build is safe — the GIL serializes it.\n\n`sys._current_frames()` returns `PyFrameObject`s whose `f_frame` points at **another running thread's live `_PyInterpreterFrame`**. Reading any attribute (`f_lineno`, `f_lasti`, `f_globals`, …) dereferences that frame with **no synchronization** while the owning thread concurrently materializes/pops it (`take_ownership`, `Python/frame.c`). So **pure-Python code can segfault the interpreter** (use-after-free).\n\nThis is documented as unsafe in the free-threading HOWTO, but it is a *memory-safety crash reachable from pure Python*. It is the gap left by **gh-117300** (PR #117301, closed): that change stop-the-world's only the *dict snapshot*, not the subsequent frame-attribute reads — which is why the HOWTO's \"may crash\" warning *post-dates* the fix. ThreadSanitizer on a free-threaded build flags the race in `frame_getlineno` ↔ `take_ownership` / `_PyFrame_GetCode`.\n\n## Related\n\n- **gh-117300** / PR #117301 (closed, @colesbury) — the parent: STW'd the snapshot only; this is the remaining read-path race.\n- **DataDog dd-trace-py #13567** — the same UAF in the wild: a production profiler takes a fatal SIGSEGV dereferencing a stale frame from `sys._current_frames()` / `_PyThread_CurrentFrames`.\n- **gh-106883** — a related (different) hazard: deadlock when using `sys._current_frames` under threads.\n\ncc @colesbury (free-threaded frames / gh-117300).\n\n## Repro (segfaults within seconds on a free-threaded build)\n\n```python\nimport sys, threading\n\ndef recurse(n):\n    return recurse(n - 1) if n else 0\n\nstop = False\ndef worker():\n    while not stop:\n        recurse(60)          # constantly pushes/pops _PyInterpreterFrames\n\nt = threading.Thread(target=worker); t.start()\ntry:\n    while True:\n        for fr in sys._current_frames().values():\n            fr.f_lineno      # reads the worker's LIVE frame -\u003e use-after-free\nfinally:\n    stop = True; t.join()\n```\n\n## Proposed minimal fix — `frame_read_sync.patch`\n\nSerialize the frame reader against `take_ownership` with the frame object's own critical section (`Py_BEGIN_CRITICAL_SECTION(f)`). The reader then sees either the pre-materialize live frame or the post-materialize embedded copy — never a torn `f_frame` nor a freed `_PyInterpreterFrame`. The other attribute readers (`frame_getlasti`, `frame_getglobals`, `frame_getbuiltins`, …) need the same wrap; the patch shows the pattern on `f_lineno` (the repro path).\n\n\u003e **Status: proposed.** Generated against CPython 3.13.13; applies cleanly. NOT yet run against the CPython test suite / TSan oracle — treat as a starting point.\n\n### CPython versions tested on:\n\n3.13\n\n### Operating systems tested on:\n\nLinux\n\n### Output from running 'python -VV' on the command line:\n\nCPython 3.13.13","author":{"url":"https://github.com/robertsdotpm","@type":"Person","name":"robertsdotpm"},"datePublished":"2026-06-27T00:33:16.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/152355/cpython/issues/152355"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:0a7cdb28-df8f-1137-3df5-d7502e86d242
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB4F8:23D81D:663FB8:86670B:6A530244
html-safe-noncef6810af43ef4fb95b05c27be947ec7e767c1dcff83f55ef81c6da55ac1e19212
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNEY4OjIzRDgxRDo2NjNGQjg6ODY2NzBCOjZBNTMwMjQ0IiwidmlzaXRvcl9pZCI6IjcyMDY0MTQzMTUwNzQ4MTQ1MzIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacd072dbfa03daccbf534916716693b48dd080796c32e5b6aa534a0de3808da582
hovercard-subject-tagissue:4755942842
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/152355/issue_layout
twitter:imagehttps://opengraph.githubassets.com/05a19bb453171350fb97bdb21752fca59963d930a0861d7372704231b280d5f0/python/cpython/issues/152355
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/05a19bb453171350fb97bdb21752fca59963d930a0861d7372704231b280d5f0/python/cpython/issues/152355
og:image:altCrash report What happened? frame_read_sync.patch Free-threaded build: reading a sys._current_frames() frame is a use-after-free Affects: free-threaded build only (--disable-gil; python3.13t, PYTHO...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamerobertsdotpm
hostnamegithub.com
expected-hostnamegithub.com
Noneb9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb
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
release07a982c1d40157c619b364352b704c3ce66bb332
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/issues/152355#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F152355
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
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
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://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
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F152355
Sign up https://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/152355
Reloadhttps://github.com/python/cpython/issues/152355
Reloadhttps://github.com/python/cpython/issues/152355
Please reload this pagehttps://github.com/python/cpython/issues/152355
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/issues/152355
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 35k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 73.8k https://github.com/login?return_to=%2Fpython%2Fcpython
Code https://github.com/python/cpython
Issues 5k+ https://github.com/python/cpython/issues
Pull requests 2.3k https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security and quality 0 https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
Code https://github.com/python/cpython
Issues https://github.com/python/cpython/issues
Pull requests https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security and quality https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
Free-threaded build: reading a sys._current_frames() frame is a use-after-freehttps://github.com/python/cpython/issues/152355#top
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
topic-free-threadinghttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-free-threading%22
type-crashA hard crash of the interpreter, possibly with a core dumphttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-crash%22
https://github.com/robertsdotpm
robertsdotpmhttps://github.com/robertsdotpm
on Jun 27, 2026https://github.com/python/cpython/issues/152355#issue-4755942842
frame_read_sync.patchhttps://github.com/user-attachments/files/29399904/frame_read_sync.patch
gh-117300https://github.com/python/cpython/issues/117300
#117301https://github.com/python/cpython/pull/117301
Use stop-the-world to make sys._current_frames() and sys._current_exceptions() thread-safe in free-threaded build #117300https://github.com/python/cpython/issues/117300
gh-117300: Use stop the world to make sys._current_frames and sys._current_exceptions thread-safe. #117301https://github.com/python/cpython/pull/117301
@colesburyhttps://github.com/colesbury
bpo-26836: Add os.memfd_create() #13567https://github.com/python/cpython/pull/13567
Deadlock in threaded application when using sys._current_frames #106883https://github.com/python/cpython/issues/106883
@colesburyhttps://github.com/colesbury
gh-117300https://github.com/python/cpython/issues/117300
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
topic-free-threadinghttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-free-threading%22
type-crashA hard crash of the interpreter, possibly with a core dumphttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-crash%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.