René's URL Explorer Experiment


Title: Issue · GitHub

Open Graph Title: Issue · python/cpython

X Title: Issue · python/cpython

Description: The Python programming language. Contribute to python/cpython development by creating an account on GitHub.

Open Graph Description: The Python programming language. Contribute to python/cpython development by creating an account on GitHub.

X Description: The Python programming language. Contribute to python/cpython development by creating an account on GitHub.

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Crash in repr() for lists containing NULLs","articleBody":"# Crash report\n\n### What happened?\n\nIt's possible to segfault the interpreter from a double-free in `xml.etree.ElementTree.TreeBuilder`. Please let me know if the automated diagnosis is incorrect and whether you prefer me not to post it in new issues.\n\n### Automated diagnosis:\n\n**Missing Py_NewRef causes double-free in treebuilder_handle_end (line 2851)**: `Py_XSETREF(self-\u003elast_for_tail, self-\u003elast)` stores into `last_for_tail` without taking a new reference. Both fields point to the same object with only one reference. `treebuilder_gc_clear` decrements twice — a double-free triggered on every XML end tag. Lines 2882 and 2922 demonstrate the correct pattern with `Py_NewRef`.\nFix: `Py_XSETREF(self-\u003elast_for_tail, Py_NewRef(self-\u003elast));`\n\nMRE:\n```python\nimport xml.etree.ElementTree\nimport gc\n\nbuilder = xml.etree.ElementTree.TreeBuilder()\nfor x in range(10):\n    builder.start(\"a\", {})\nfor x in range(10):\n    builder.end(\"a\")\nroot = builder.close()\nprint(gc.get_referrers(root[0]))\n```\n\nBacktrace:\n```\nProgram received signal SIGSEGV, Segmentation fault.\n0x0000555555b5ca97 in Py_INCREF (op=0x0) at ./Include/refcount.h:281\n281         PY_UINT32_T cur_refcnt = op-\u003eob_refcnt;\n(gdb) bt\n#0  0x0000555555b5ca97 in Py_INCREF (op=0x0) at ./Include/refcount.h:281\n#1  _Py_NewRef (obj=0x0) at ./Include/refcount.h:529\n#2  list_repr_impl (v=0x7c6ff70471a0) at Objects/listobject.c:604\n#3  list_repr (self=0x7c6ff70471a0) at Objects/listobject.c:644\n#4  0x0000555555bf05dc in PyObject_Repr (v=v@entry=0x7c6ff70471a0) at Objects/object.c:781\n#5  0x0000555555cdc514 in PyUnicodeWriter_WriteRepr (writer=writer@entry=0x7c6ff71b2390, obj=obj@entry=0x7c6ff70471a0) at Objects/unicode_writer.c:390\n#6  0x0000555555b5cb0b in list_repr_impl (v=0x7c6ff70749a0) at Objects/listobject.c:615\n#7  list_repr (self=0x7c6ff70749a0) at Objects/listobject.c:644\n#8  0x0000555555bf028b in PyObject_Str (v=0x7c6ff70749a0) at Objects/object.c:823\n#9  0x0000555555b26f23 in PyFile_WriteObject (v=0x7c6ff70749a0, f=0x7d0ff70126a0, flags=flags@entry=1) at Objects/fileobject.c:119\n#10 0x0000555555e4de11 in builtin_print_impl (module=0x7ccff6fe6450, objects=0x7bfff5db6b28, objects_length=1, sep=0x0, end=0x0, file=0x7d0ff70126a0, flush=0) at Python/bltinmodule.c:2356\n#11 builtin_print (module=\u003coptimized out\u003e, args=\u003coptimized out\u003e, nargs=\u003coptimized out\u003e, kwnames=0x0) at Python/clinic/bltinmodule.c.h:1122\n#12 0x0000555555bde65c in cfunction_vectorcall_FASTCALL_KEYWORDS (func=func@entry=0x7c7ff70374c0, args=args@entry=0x7bfff5db6b28, nargsf=nargsf@entry=9223372036854775809,\n    kwnames=kwnames@entry=0x0) at Objects/methodobject.c:465\n#13 0x0000555555ab9e00 in _PyObject_VectorcallTstate (tstate=0x5555568f7b18 \u003c_PyRuntime+360664\u003e, callable=0x7c7ff70374c0, args=0x7bfff5db6b28, nargsf=9223372036854775809, kwnames=0x0)\n    at ./Include/internal/pycore_call.h:136\n#14 0x0000555555e588dd in _Py_VectorCallInstrumentation_StackRefSteal (callable=..., arguments=\u003coptimized out\u003e, total_args=1, kwnames=..., call_instrumentation=\u003coptimized out\u003e,\n    frame=\u003coptimized out\u003e, this_instr=\u003coptimized out\u003e, tstate=\u003coptimized out\u003e) at Python/ceval.c:770\n#15 0x0000555555e94263 in _PyEval_EvalFrameDefault (tstate=\u003coptimized out\u003e, frame=\u003coptimized out\u003e, throwflag=\u003coptimized out\u003e) at Python/generated_cases.c.h:1838\n#16 0x0000555555e57778 in _PyEval_EvalFrame (tstate=0x5555568f7b18 \u003c_PyRuntime+360664\u003e, frame=0x7e8ff6fe5220, throwflag=0) at ./Include/internal/pycore_ceval.h:118\n#17 _PyEval_Vector (tstate=\u003coptimized out\u003e, func=\u003coptimized out\u003e, locals=\u003coptimized out\u003e, args=\u003coptimized out\u003e, argcount=\u003coptimized out\u003e, kwnames=0x0) at Python/ceval.c:2134\n#18 0x0000555555e57195 in PyEval_EvalCode (co=\u003coptimized out\u003e, globals=\u003coptimized out\u003e, locals=0x7c7ff70884c0) at Python/ceval.c:681\n#19 0x0000555556061fb0 in run_eval_code_obj (tstate=tstate@entry=0x5555568f7b18 \u003c_PyRuntime+360664\u003e, co=co@entry=0x7d5ff6ffe990, globals=globals@entry=0x7c7ff70884c0,\n    locals=locals@entry=0x7c7ff70884c0) at Python/pythonrun.c:1368\n```\n\n### Claude explanation of the MRE and crash:\n\n1. The loop calls `builder.end(\"a\")` 10 times, each time executing line 2851: `Py_XSETREF(self-\u003elast_for_tail, self-\u003elast)` — missing `Py_NewRef`. Each end tag over-decrements the element it touches.\n2. After `builder.close()`, `root[0]` (the innermost `\u003ca\u003e`) has had its refcount corrupted — it's lower than it should be.\n3. `gc.get_referrers(root[0])` returns a list containing objects that reference that element. One of those referrers is the `TreeBuilder`'s internal stack list, which itself contains elements with corrupted refcounts.\n4. `print()` calls `list_repr` on that referrers list, which calls `Py_NewRef` on each item. When it hits an element whose refcount was decremented to 0 (already freed), `op` is `NULL` or points to freed memory → segfault at `Py_INCREF(op=0x0)`.\n\nThe backtrace confirms it: `list_repr_impl` at `listobject.c:604` tries to `Py_NewRef` a `NULL` pointer — an object that was prematurely freed due to the cumulative over-decrements from the 10 `end()` calls.\n\n----\n\nFound using [cpython-review-toolkit](https://github.com/devdanzin/cpython-review-toolkit).\n\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nLinux\n\n### Output from running 'python -VV' on the command line:\n\nPython 3.15.0a7+ (heads/main:99e2c5eccd2, Mar 17 2026, 08:26:50) [Clang 21.1.2 (2ubuntu6)]\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-146062\n* gh-146129\n* gh-146155\n* gh-146167\n* gh-146204\n* gh-146213\n* gh-146271\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/devdanzin","@type":"Person","name":"devdanzin"},"datePublished":"2026-03-17T12:19:15.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":7},"url":"https://github.com/146056/cpython/issues/146056"}

route-pattern/:user_id/:repository/issues/:id(.:format)
route-controllerissues
route-actionshow
fetch-noncev2:9fbd2a4f-7cf3-629c-2e2d-44738f88e7b0
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idAA92:1179A2:709C5E:978C0C:6A50512E
html-safe-nonce1074e85c2af55a23794b8fe61de04ef25ce558473af16625a24b2180a1da9d55
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQTkyOjExNzlBMjo3MDlDNUU6OTc4QzBDOjZBNTA1MTJFIiwidmlzaXRvcl9pZCI6IjUwNzE4MDU1MDU4NTQyNjM1OTgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac11c332bb42f23308e6a9b11ad07fb077c8161e16823c7c2946b0de8e69aec323
hovercard-subject-tagrepository:81598961
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///issues/show
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python/cpython/issues/146056
twitter:imagehttps://opengraph.githubassets.com/c11528776ec9d44b60e65ad5d78f9e93de4841b81b2a70f52148660bc6f5c260/python/cpython
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/c11528776ec9d44b60e65ad5d78f9e93de4841b81b2a70f52148660bc6f5c260/python/cpython
og:image:altThe Python programming language. Contribute to python/cpython development by creating an account on GitHub.
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Noned6dc8294eb500fa36bbc57472d61fe87c522f9c3c1d64f70f4926f66a66a7efb
turbo-cache-controlno-cache
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
release5741a45fe07e5f377d0d4c524a92e3056acc51bb
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/issues/146056#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F146056
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%2F146056
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%2Fissues%2Fshow&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/146056
Reloadhttps://github.com/python/cpython/issues/146056
Reloadhttps://github.com/python/cpython/issues/146056
Please reload this pagehttps://github.com/python/cpython/issues/146056
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/issues/146056
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 34.9k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 73.6k 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
Crash in repr() for lists containing NULLshttps://github.com/python/cpython/issues/146056#top
extension-modulesC modules in the Modules dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22extension-modules%22
topic-XMLhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-XML%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/devdanzin
devdanzinhttps://github.com/devdanzin
on Mar 17, 2026https://github.com/python/cpython/issues/146056#issue-4088191804
cpython-review-toolkithttps://github.com/devdanzin/cpython-review-toolkit
gh-146056: Fix TreeBuilder stack in xml.etree #146062https://github.com/python/cpython/pull/146062
gh-146056: Fix repr() for lists and tuples containing NULLs #146129https://github.com/python/cpython/pull/146129
[3.14] gh-146056: Fix repr() for lists and tuples containing NULLs (GH-146129) #146155https://github.com/python/cpython/pull/146155
gh-146056: Rework ref counting in treebuilder_handle_end() #146167https://github.com/python/cpython/pull/146167
[3.14] gh-146056: Fix repr() for lists and tuples containing NULLs (GH-146129) (alt) #146204https://github.com/python/cpython/pull/146204
Update docs for gh-146056 #146213https://github.com/python/cpython/pull/146213
[3.13] gh-146056: Fix repr() for lists containing NULLs (GH-146129) (GH-146155) #146271https://github.com/python/cpython/pull/146271
extension-modulesC modules in the Modules dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22extension-modules%22
topic-XMLhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-XML%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.