René's URL Explorer Experiment


Title: Segfault when cleaning up after a MemoryError with deeply nested objects · Issue #149146 · python/cpython · GitHub

Open Graph Title: Segfault when cleaning up after a MemoryError with deeply nested objects · Issue #149146 · python/cpython

X Title: Segfault when cleaning up after a MemoryError with deeply nested objects · Issue #149146 · python/cpython

Description: Crash report What happened? When in memory-constrained situations, the following code generates a segfault on main: b = 9 while True: b = (b, None) Clearly, b grows to be an unbounded nested tuple, which eventually exhausts the memory. A...

Open Graph Description: Crash report What happened? When in memory-constrained situations, the following code generates a segfault on main: b = 9 while True: b = (b, None) Clearly, b grows to be an unbounded nested tuple,...

X Description: Crash report What happened? When in memory-constrained situations, the following code generates a segfault on main: b = 9 while True: b = (b, None) Clearly, b grows to be an unbounded nested tuple,...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Segfault when cleaning up after a MemoryError with deeply nested objects","articleBody":"# Crash report\n\n### What happened?\n\nWhen in memory-constrained situations, the following code generates a segfault on main:\n\n```python\nb = 9\nwhile True:\n    b = (b, None)\n```\n\nClearly, b grows to be an unbounded nested tuple, which eventually exhausts the memory.\nA MemoryError is correctly thrown, but during unwind, python tries to clean up the object, and this triggers a stack overflow.\n\n\u003cdetails\u003e\n\u003csummary\u003eExample stack\u003c/summary\u003e\n\n```\nProcess 369 stopped\n\nThread 1 \"fuzz_python\" stop reason = signal SIGSEGV\n  frame #0: frame #0: 0x0000aaaaaea31648 fuzz_python`tuple_dealloc(self=0x0000ffff9fa045e0) at tupleobject.c:256\n  frame #1: frame #1: 0x0000aaaaae9ccd54 fuzz_python`_Py_Dealloc(op=0x0000ffff9fa045e0) at object.c:3303:5\n  frame #2: frame #2: 0x0000aaaaaea3182c fuzz_python`Py_DECREF(op=\u003cunavailable\u003e) at refcount.h:427:9 [inlined]\n  frame #3: frame #3: 0x0000aaaaaea3180c fuzz_python`Py_XDECREF(op=\u003cunavailable\u003e) at refcount.h:520:9 [inlined]\n  frame #4: frame #4: 0x0000aaaaaea31804 fuzz_python`tuple_dealloc(self=0x0000ffff9fa04630) at tupleobject.c:277:9\n  frame #5: frame #5: 0x0000aaaaae9ccd54 fuzz_python`_Py_Dealloc(op=0x0000ffff9fa04630) at object.c:3303:5\n  frame #6: frame #6: 0x0000aaaaaea3182c fuzz_python`Py_DECREF(op=\u003cunavailable\u003e) at refcount.h:427:9 [inlined]\n  frame #7: frame #7: 0x0000aaaaaea3180c fuzz_python`Py_XDECREF(op=\u003cunavailable\u003e) at refcount.h:520:9 [inlined]\n...\n  frame #2709: frame #2709: 0x0000aaaaae9ccd54 fuzz_python`_Py_Dealloc(op=0x0000ffff9fa11cd0) at object.c:3303:5\n  frame #2710: frame #2710: 0x0000aaaaaea3182c fuzz_python`Py_DECREF(op=\u003cunavailable\u003e) at refcount.h:427:9 [inlined]\n  frame #2711: frame #2711: 0x0000aaaaaea3180c fuzz_python`Py_XDECREF(op=\u003cunavailable\u003e) at refcount.h:520:9 [inlined]\n  frame #2712: frame #2712: 0x0000aaaaaea31804 fuzz_python`tuple_dealloc(self=0x0000ffff9fa11d20) at tupleobject.c:277:9\n  frame #2713: frame #2713: 0x0000aaaaae9ccd54 fuzz_python`_Py_Dealloc(op=0x0000ffff9fa11d20) at object.c:3303:5\n  frame #2714: frame #2714: 0x0000aaaaaea3182c fuzz_python`Py_DECREF(op=\u003cunavailable\u003e) at refcount.h:427:9 [inlined]\n  frame #2715: frame #2715: 0x0000aaaaaea3180c fuzz_python`Py_XDECREF(op=\u003cunavailable\u003e) at refcount.h:520:9 [inlined]\n  frame #2716: frame #2716: 0x0000aaaaaea31804 fuzz_python`tuple_dealloc(self=0x0000ffff9fa11d70) at tupleobject.c:277:9\n  frame #2717: frame #2717: 0x0000aaaaae9ccd54 fuzz_python`_Py_Dealloc(op=0x0000ffff9fa11d70) at object.c:3303:5\n  frame #2718: frame #2718: 0x0000aaaaaea3182c fuzz_python`Py_DECREF(op=\u003cunavailable\u003e) at refcount.h:427:9 [inlined]\n  frame #2719: frame #2719: 0x0000aaaaaea3180c fuzz_python`Py_XDECREF(op=\u003cunavailable\u003e) at refcount.h:520:9 [inlined]\n  frame #2720: frame #2720: 0x0000aaaaaea31804 fuzz_python`tuple_dealloc(self=0x0000ffff9fa11dc0) at tupleobject.c:277:9\n  frame #2721: frame #2721: 0x0000aaaaae9ccd54 fuzz_python`_Py_Dealloc(op=0x0000ffff9fa11dc0) at object.c:3303:5\n  frame #2722: frame #2722: 0x0000aaaaae98f290 fuzz_python`Py_DECREF(op=\u003cunavailable\u003e) at refcount.h:427:9 [inlined]\n  frame #2723: frame #2723: 0x0000aaaaae98f26c fuzz_python`Py_XDECREF(op=\u003cunavailable\u003e) at refcount.h:520:9 [inlined]\n  frame #2724: frame #2724: 0x0000aaaaae98f26c fuzz_python`dictkeys_decref(dk=0x0000ffffbe045210, use_qsbr=false) at dictobject.c:495:17\n  frame #2725: frame #2725: 0x0000aaaaae98630c fuzz_python`dict_dealloc(self=0x0000ffffbe055f40) at dictobject.c:0\n  frame #2726: frame #2726: 0x0000aaaaae9ccd54 fuzz_python`_Py_Dealloc(op=0x0000ffffbe055f40) at object.c:3303:5\n  frame #2727: frame #2727: 0x0000aaaaae7ecb8c fuzz_python`Py_DECREF(op=0x0000ffffbe055f40) at refcount.h:427:9 [inlined]\n  frame #2728: frame #2728: 0x0000aaaaae7ecb58 fuzz_python`main(argc=1, argv=0x0000fffff67f4238) at fuzz_python.c:226:17\n  frame #2729: frame #2729: 0x0000ffffbe1e1f9c ld-musl-aarch64.so.1`libc_start_main_stage2(main=(fuzz_python`main at fuzz_python.c:71), argc=1, argv=0x0000fffff67f4238) at __libc_start_main.c:95:2\n```\n\n\u003c/details\u003e\n\nThe following dockerfile reliably reproduces it for me:\n\n\u003cdetails\u003e\n\u003csummary\u003eDockerfile\u003c/summary\u003e\n\n```\nFROM alpine:latest\n\nRUN apk add --no-cache \\\n    git build-base linux-headers openssl-dev zlib-dev bzip2-dev \\\n    xz-dev sqlite-dev readline-dev libffi-dev ncurses-dev gdbm-dev \\\n    tcl-dev tk-dev\n\nWORKDIR /src\nRUN git clone --depth=1 https://github.com/python/cpython.git\nWORKDIR /src/cpython\nRUN ./configure \u0026\u0026 make -j2\n\nRUN cat \u003e /tc.py \u003c\u003c'PY'\nb = 9\nwhile True:\n    b = (b, None)\nPY\n\nRUN cat \u003e /entrypoint.sh \u003c\u003c'SH'\n#!/bin/sh\n\necho \"Running test\"\n# 512 MiB virtual memory limit\nulimit -v 524288\n\n/src/cpython/python /tc.py\necho \"Python process exited with code $?\"\nSH\n\nRUN chmod +x /entrypoint.sh\nENTRYPOINT [\"/entrypoint.sh\"]\n```\n\n\u003c/details\u003e\n\nGives me:\n```\n\u003edocker run --rm -it 29apr\nRunning test\nTraceback (most recent call last):\n  File \"/tc.py\", line 3, in \u003cmodule\u003e\nobject address  : 0xffffae809fc0\nobject refcount : 3\nobject type     : 0xaaaad32175a8\nobject type name: MemoryError\nobject repr     : MemoryError()\nlost sys.stderr\nSegmentation fault\nPython process exited with code 139\n```\n\nISTR that stack overflows from recursive objects were at least considered low priority, if not 'not worth fixing' before, but I can't recall where I read that, it was a while ago, so apologies if this isn't a useful report!\n\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.0a8+ (heads/main:d4eee16, Apr 29 2026, 11:03:26) [GCC 15.2.0]\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-151595\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/stestagg","@type":"Person","name":"stestagg"},"datePublished":"2026-04-29T11:14:31.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":10},"url":"https://github.com/149146/cpython/issues/149146"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:d9ee174b-8874-ab2f-5d6b-ef82711f1e88
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB2AA:18AAA8:1D404EB:281734D:6A540BE8
html-safe-nonced30260960749ddbdb48f5052c3c24ad8894c9eed851567a08a60fea8a65756ca
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMkFBOjE4QUFBODoxRDQwNEVCOjI4MTczNEQ6NkE1NDBCRTgiLCJ2aXNpdG9yX2lkIjoiMzU5Mjk1NzkyMTIwNDYzNjY0OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac41f8e62dcd6c60900ce163cc569abae278b4f6557ff1dbfa0dad7a4483b957ee
hovercard-subject-tagissue:4350054959
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/149146/issue_layout
twitter:imagehttps://opengraph.githubassets.com/998b6997ca41d4eb8b46966c2c8c79262bcc6d0163a3c79f229328d63fa5de14/python/cpython/issues/149146
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/998b6997ca41d4eb8b46966c2c8c79262bcc6d0163a3c79f229328d63fa5de14/python/cpython/issues/149146
og:image:altCrash report What happened? When in memory-constrained situations, the following code generates a segfault on main: b = 9 while True: b = (b, None) Clearly, b grows to be an unbounded nested tuple,...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamestestagg
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-targetcanary-2
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/issues/149146#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F149146
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%2F149146
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/149146
Reloadhttps://github.com/python/cpython/issues/149146
Reloadhttps://github.com/python/cpython/issues/149146
Please reload this pagehttps://github.com/python/cpython/issues/149146
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/issues/149146
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
Segfault when cleaning up after a MemoryError with deeply nested objectshttps://github.com/python/cpython/issues/149146#top
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/stestagg
stestagghttps://github.com/stestagg
on Apr 29, 2026https://github.com/python/cpython/issues/149146#issue-4350054959
gh-149146: Add dealloc-depth counter fallback to trashcan trigger #151595https://github.com/python/cpython/pull/151595
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.