René's URL Explorer Experiment


Title: Crash in HAMT during garbage collection · Issue #148891 · python/cpython · GitHub

Open Graph Title: Crash in HAMT during garbage collection · Issue #148891 · python/cpython

X Title: Crash in HAMT during garbage collection · Issue #148891 · python/cpython

Description: Crash report What happened? We discovered a crash in the https://github.com/datadog/dd-trace-py library we maintain that actually seems to be rooted in CPython, not our own code. Error UnixSignal: Process terminated with SEGV_MAPERR (SIG...

Open Graph Description: Crash report What happened? We discovered a crash in the https://github.com/datadog/dd-trace-py library we maintain that actually seems to be rooted in CPython, not our own code. Error UnixSignal: ...

X Description: Crash report What happened? We discovered a crash in the https://github.com/datadog/dd-trace-py library we maintain that actually seems to be rooted in CPython, not our own code. Error UnixSignal: ...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Crash in HAMT during garbage collection","articleBody":"# Crash report\n\n### What happened?\n\nWe discovered a crash in the https://github.com/datadog/dd-trace-py library we maintain that actually seems to be rooted in CPython, not our own code.\n\n```\nError UnixSignal: Process terminated with SEGV_MAPERR (SIGSEGV)\n#0  0x00007fc92c3dd27f PyObject_GC_UnTrack\n#1  0x00007fc92c4e1448 PyContextVar_Set\n#2  0x00007fc92c3f3546 _PyEval_EvalFrameDefault\n#3  0x00007fc92c3fbce7 PyObject_Vectorcall\n#4  0x00007fc92c3f039b _PyEval_EvalFrameDefault\n#5  0x00007fc92c3f2f38 _PyEval_EvalFrameDefault\n#6  0x00007fc92c3f2f38 _PyEval_EvalFrameDefault\n#7  0x00007fc92c3f2f38 _PyEval_EvalFrameDefault\n#8  0x00007fc92c3f2f38 _PyEval_EvalFrameDefault\n#9  0x00007fc92c44e25f PyIter_Send\n#10 0x00007fc92c3f2f38 _PyEval_EvalFrameDefault\n#11 0x00007fc92c3f2f38 _PyEval_EvalFrameDefault\n#12 0x00007fc92c3f2f38 _PyEval_EvalFrameDefault\n#13 0x00007fc92c3f2f38 _PyEval_EvalFrameDefault\n#14 0x00007fc92c3f2f38 _PyEval_EvalFrameDefault\n#15 0x00007fc92c3f2f38 _PyEval_EvalFrameDefault\n#16 0x00007fc92c3f2f38 _PyEval_EvalFrameDefault\n#17 0x00007fc92c3f2f38 _PyEval_EvalFrameDefault\n#18 0x00007fc92c3f2f38 _PyEval_EvalFrameDefault\n#19 0x00007fc92c3f2f38 _PyEval_EvalFrameDefault\n#20 0x00007fc92c3f2f38 _PyEval_EvalFrameDefault\n#21 0x00007fc92c3f2f38 _PyEval_EvalFrameDefault\n#22 0x00007fc92c3f2f38 _PyEval_EvalFrameDefault\n#23 0x00007fc92c3f2f38 _PyEval_EvalFrameDefault\n#24 0x00007fc92c3f2f38 _PyEval_EvalFrameDefault\n#25 0x00007fc92c3f2f38 _PyEval_EvalFrameDefault\n#26 0x00007fc92c3f2f38 _PyEval_EvalFrameDefault\n#27 0x00007fc92c3f2f38 _PyEval_EvalFrameDefault\n#28 0x00007fc92c3f2f38 _PyEval_EvalFrameDefault\n#29 0x00007fc92c3f2f38 _PyEval_EvalFrameDefault\n#30 0x00007fc92c3f2f38 _PyEval_EvalFrameDefault\n#31 0x00007fc92c3f2f38 _PyEval_EvalFrameDefault\n#32 0x00007fc92c3f2f38 _PyEval_EvalFrameDefault\n#33 0x00007fc92c3f2f38 _PyEval_EvalFrameDefault\n#34 0x00007fc8f1f854ff __Pyx_PyObject_Call (/project/uvloop/loop.c:191431:15)\n#35 0x00007fc8f204f948 __pyx_f_6uvloop_4loop_6Handle__run (/project/uvloop/loop.c:66901:25)\n#36 0x00007fc8f2053f7c __pyx_f_6uvloop_4loop_4Loop__on_idle (/project/uvloop/loop.c:17975:25)\n#37 0x00007fc8f204f9a6 __pyx_f_6uvloop_4loop_6Handle__run (/project/uvloop/loop.c:66927:24)\n#38 0x00007fc8f2051047 __pyx_f_6uvloop_4loop_cb_idle_callback (/project/uvloop/loop.c:87335:19)\n#39 0x00007fc8f20687d1 uv__run_idle (/project/build/libuv-x86_64/src/unix/loop-watcher.c:68:1)\n#40 0x00007fc8f2065b07 uv_run (/project/build/libuv-x86_64/src/unix/core.c:439:5)\n#41 0x00007fc8f1fb83a0 __pyx_f_6uvloop_4loop_4Loop__Loop__run (/project/uvloop/loop.c:18458:23)\n#42 0x00007fc8f1ff612d __pyx_f_6uvloop_4loop_4Loop__run (/project/uvloop/loop.c:18876:18)\n#43 0x00007fc8f1ff1e85 __pyx_pf_6uvloop_4loop_4Loop_24run_forever (/project/uvloop/loop.c:31528:18)\n#44 0x00007fc8f1ff1e85 __pyx_pw_6uvloop_4loop_4Loop_25run_forever (/project/uvloop/loop.c:31331:13)\n#45 0x00007fc92c3ec26e PyObject_VectorcallMethod\n#46 0x00007fc92c3f039b _PyEval_EvalFrameDefault\n#47 0x00007fc92c47474c PyEval_EvalCode\n#48 0x00007fc92c4a24a7 _PyRun_SimpleFileObject\n#49 0x00007fc92c4a1b38 _PyRun_AnyFileObject\n#50 0x00007fc92c49c3be Py_RunMain\n#51 0x00007fc92c46461b Py_BytesMain\n#52 0x00007fc92c067d65 __libc_start_main\n#53 0x0000559068986071 _start\n```\n\nWe fixed the crash on our side with https://github.com/DataDog/dd-trace-py/pull/17407 but figured it might still be worth reporting upstream.\n\nThe crash happens in `PyObject_GC_UnTrack`, called from the dealloc path of a HAMT node that `PyContextVar_Set` is trying to free via `Py_DECREF`.  If that HAMT node's memory is already unmapped, the `PyObject_GC_UnTrack` write faults.\n\nWe discovered that crash in `dd-trace-py` accidentally because of the following code:\n1. Store a fresh `{}` dict in the context's HAMT under `self._storage`\n2. Put the `Token` returned by `set()` back into that same dict\n\n```python\ndef __enter__(self) -> \"BaseWrappingContext\":\n    token: Token = self._storage.set({})          # 1. create new HAMT entry\n    self._storage.get()[\"__dd_wrapping_context_token__\"] = token  # 2. store Token in dict\n    return self\n```\n\n`Token` objects holds `tok_ctx`, which is a strong reference to the `PyContext` that was active when `set` was called -- i.e. `ts->context`.\n\nI unfortunately don't have a proposed fix yet, but I'm looking into it.\n\n### CPython versions tested on:\n\n~3.12~ \n\nEDIT: this is happening on 3.12 but the stack I originally reported (and most crashes I see) are coming from Python 3.10 and 3.11.\n\n### Operating systems tested on:\n\nLinux\n\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-148928\n* gh-161592\n* gh-161593\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/KowalskiThomas","@type":"Person","name":"KowalskiThomas"},"datePublished":"2026-04-22T20:08:12Z","url":"https://github.com/python/cpython/issues/148891"}

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:6ec1aee7-39fc-c3e5-7784-6dbcb31cb588
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idD3F4:148EE1:50AADE:65ECAA:6B020374
html-safe-nonce909d77372b84c13f45dfa333213d27627c43b92d91d7dc8f3332a23a5ac5cf11
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEM0Y0OjE0OEVFMTo1MEFBREU6NjVFQ0FBOjZCMDIwMzc0IiwidmlzaXRvcl9pZCI6Ijg3OTQ3NTg0MjIwMjMzODE2NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac4fbffc1259333bdfa28348c51d1f2e56c5ae17c08a911b2db4d33e6e21912593
hovercard-subject-tagissue:4311579136
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/148891/issue_layout
twitter:imagehttps://opengraph.githubassets.com/905c9f9ceb51a55a6b9bd589c3fbd8aa3b2f0cd57863961153b9d38fa5c5855a/python/cpython/issues/148891
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/905c9f9ceb51a55a6b9bd589c3fbd8aa3b2f0cd57863961153b9d38fa5c5855a/python/cpython/issues/148891
og:image:altCrash report What happened? We discovered a crash in the https://github.com/datadog/dd-trace-py library we maintain that actually seems to be rooted in CPython, not our own code. Error UnixSignal: ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameKowalskiThomas
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/148891#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F148891
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%2F148891
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/148891
Reloadhttps://github.com/python/cpython/issues/148891
Reloadhttps://github.com/python/cpython/issues/148891
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/148891
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/148891
#148928https://github.com/python/cpython/pull/148928
Crash in HAMT during garbage collectionhttps://github.com/python/cpython/issues/148891#top
#148928https://github.com/python/cpython/pull/148928
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%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/KowalskiThomas
KowalskiThomashttps://github.com/KowalskiThomas
on Apr 22, 2026https://github.com/python/cpython/issues/148891#issue-4311579136
https://github.com/datadog/dd-trace-pyhttps://github.com/datadog/dd-trace-py
DataDog/dd-trace-py#17407https://github.com/DataDog/dd-trace-py/pull/17407
gh-148891: prevent crash in HAMT #148928https://github.com/python/cpython/pull/148928
[3.14] gh-148891: prevent crash in HAMT caused by GC during traverse (GH-148928) #161592https://github.com/python/cpython/pull/161592
[3.15] gh-148891: prevent crash in HAMT caused by GC during traverse (GH-148928) #161593https://github.com/python/cpython/pull/161593
KowalskiThomashttps://github.com/KowalskiThomas
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
on Apr 22, 2026https://github.com/python/cpython/issues/148891#event-24770467954
https://github.com/gvanrossum
gvanrossumhttps://github.com/gvanrossum
on Apr 22, 2026https://github.com/python/cpython/issues/148891#issuecomment-4299646961
@KowalskiThomashttps://github.com/KowalskiThomas
https://github.com/sergey-miryanov
sergey-miryanovhttps://github.com/sergey-miryanov
on Apr 22, 2026https://github.com/python/cpython/issues/148891#issuecomment-4299671225
https://github.com/KowalskiThomas
KowalskiThomashttps://github.com/KowalskiThomas
on Apr 22, 2026https://github.com/python/cpython/issues/148891#issuecomment-4299711480
picnixzhttps://github.com/picnixz
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
on Apr 22, 2026https://github.com/python/cpython/issues/148891#event-24771303364
https://github.com/KowalskiThomas
KowalskiThomashttps://github.com/KowalskiThomas
on Apr 23, 2026https://github.com/python/cpython/issues/148891#issuecomment-4302733160
main...KowalskiThomas:cpython:kowalski/fix-prevent-crash-in-hamthttps://github.com/python/cpython/compare/main...KowalskiThomas:cpython:kowalski/fix-prevent-crash-in-hamt
#142829https://github.com/python/cpython/issues/142829
https://github.com/gvanrossum
gvanrossumhttps://github.com/gvanrossum
on Apr 23, 2026https://github.com/python/cpython/issues/148891#issuecomment-4306275708
https://github.com/KowalskiThomas
KowalskiThomashttps://github.com/KowalskiThomas
on Apr 23, 2026https://github.com/python/cpython/issues/148891#issuecomment-4307050996
#148928https://github.com/python/cpython/pull/148928
https://github.com/gvanrossum
gvanrossumhttps://github.com/gvanrossum
on Apr 23, 2026https://github.com/python/cpython/issues/148891#issuecomment-4308194648
cmaloneyhttps://github.com/cmaloney
on Nov 7, 2026https://github.com/python/cpython/issues/148891#event-35461362863
gh-148891: prevent crash in HAMT caused by GC during traverse (#148928)https://github.com/python/cpython/commit/1798d4fb3ca0e1cd8f9e6ab0ac99a0a9fb1f7527
gh-148891https://github.com/python/cpython/issues/148891
#148928https://github.com/python/cpython/pull/148928
1798d4fhttps://github.com/python/cpython/commit/1798d4fb3ca0e1cd8f9e6ab0ac99a0a9fb1f7527
cmaloneyhttps://github.com/cmaloney
completedhttps://github.com/python/cpython/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#148928https://github.com/python/cpython/pull/148928
on Nov 7, 2026https://github.com/python/cpython/issues/148891#event-35461363283
cmaloneyhttps://github.com/cmaloney
on Nov 7, 2026https://github.com/python/cpython/issues/148891#event-35466499977
[3.14] gh-148891: prevent crash in HAMT caused by GC during traverse (G…https://github.com/python/cpython/commit/aee90465e55101ea1d14b28a2a5670b1802c2f18
gh-148891https://github.com/python/cpython/issues/148891
G…https://github.com/python/cpython/pull/148928
aee9046https://github.com/python/cpython/commit/aee90465e55101ea1d14b28a2a5670b1802c2f18
[3.15] gh-148891: prevent crash in HAMT caused by GC during traverse (G…https://github.com/python/cpython/commit/055e6b2891985b9ac88325c2bb544df9e3aa5a0d
gh-148891https://github.com/python/cpython/issues/148891
G…https://github.com/python/cpython/pull/148928
055e6b2https://github.com/python/cpython/commit/055e6b2891985b9ac88325c2bb544df9e3aa5a0d
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/148891
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/148891
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%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.