René's URL Explorer Experiment


Title: Assertion failure when func_repr is called on an already tp_clear-ed object · Issue #91636 · python/cpython · GitHub

Open Graph Title: Assertion failure when func_repr is called on an already tp_clear-ed object · Issue #91636 · python/cpython

X Title: Assertion failure when func_repr is called on an already tp_clear-ed object · Issue #91636 · python/cpython

Description: Crash report It is possible to resurrect a tp_clear-ed object using pure python. The following piece of code illustrates how: import gc, weakref class LateFin: __slots__ = ('ref',) def __del__(self): # 8. Now `latefin`'s finalizer is cal...

Open Graph Description: Crash report It is possible to resurrect a tp_clear-ed object using pure python. The following piece of code illustrates how: import gc, weakref class LateFin: __slots__ = ('ref',) def __del__(self...

X Description: Crash report It is possible to resurrect a tp_clear-ed object using pure python. The following piece of code illustrates how: import gc, weakref class LateFin: __slots__ = ('ref',) def __de...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Assertion failure when func_repr is called on an already tp_clear-ed object","articleBody":"\u003c!--\n  Use this template for hard crashes of the interpreter, segmentation faults, failed C-level assertions, and similar.\n  Do not submit this form if you encounter an exception being unexpectedly raised from a Python function.\n  Most of the time, these should be filed as bugs, rather than crashes.\n\n  The CPython interpreter is itself written in a different programming language, C.\n  For CPython, a \"crash\" is when Python itself fails, leading to a traceback in the C stack.\n--\u003e\n\n**Crash report**\n\nIt is possible to resurrect a `tp_clear`-ed object using pure python. The following piece of code illustrates how:\n\n```python\nimport gc, weakref\n\n\nclass LateFin:\n    __slots__ = ('ref',)\n\n    def __del__(self):\n        # 8. Now `latefin`'s finalizer is called. Here we obtain a reference to\n        # `func`, which is currently undergoing `tp_clear`.\n        global func\n        func = self.ref()\n\n\nclass Cyclic(tuple):\n    __slots__ = ()\n\n    # 4. The finalizers of all garbage objects are called. In this case this is\n    # only us as `func` doesn't have a finalizer.\n    def __del__(self):\n        # 5. Create a weakref to `func` now. If we had created it earlier, it\n        # would have been cleared by the garbage collector before calling the\n        # finalizers.\n        self[1].ref = weakref.ref(self[0])\n        # 6. Drop the global reference to `latefin`. The only remaining\n        # reference is the one we have.\n        global latefin\n        del latefin\n    # 7. Now `func` is `tp_clear`-ed. This drops the last reference to `Cyclic`,\n    # which gets `tp_dealloc`-ed. This drops the last reference to `latefin`.\n\n\nlatefin = LateFin()\nfunc = lambda: None\ncyc = tuple.__new__(Cyclic, (func, latefin))\n\n# 1. Create a reference cycle of `cyc` and `func`.\nfunc.__module__ = cyc\n\n# 2. Make the cycle unreachable, but keep the global reference to `latefin` so\n# that it isn't detected as garbage. This way its finalizer will not be called\n# immediately.\ndel func, cyc\n\n# 3. Invoke garbage collection, which will find `cyc` and `func` as garbage.\ngc.set_debug(gc.DEBUG_COLLECTABLE)\ngc.collect()\ngc.set_debug(0)\n\n# 9. Call `repr()`, which will try to use the NULL `func_qualname`.\nrepr(func)\n```\n\n```\n#5  0x00007ffff7d0a596 in __GI___assert_fail (assertion=assertion@entry=0x697e93 \"obj \u0026\u0026 _PyUnicode_CHECK(obj)\", file=file@entry=0x696a92 \"Objects/unicodeobject.c\", line=line@entry=3000, \n    function=function@entry=0x69e110 \u003c__PRETTY_FUNCTION__.299\u003e \"unicode_fromformat_arg\") at assert.c:101\n#6  0x0000000000538d8e in unicode_fromformat_arg (writer=writer@entry=0x7fffffffd9f0, f=0x682bf1 \"U at %p\u003e\", f@entry=0x682bf0 \"%U at %p\u003e\", vargs=vargs@entry=0x7fffffffda28)\n    at Objects/unicodeobject.c:3000\n#7  0x0000000000539098 in PyUnicode_FromFormatV (format=\u003coptimized out\u003e, vargs=vargs@entry=0x7fffffffda68) at Objects/unicodeobject.c:3109\n#8  0x00000000005391ab in PyUnicode_FromFormat (format=format@entry=0x682be6 \"\u003cfunction %U at %p\u003e\") at Objects/unicodeobject.c:3161\n#9  0x00000000004c2c7b in func_repr (op=\u003coptimized out\u003e) at Objects/funcobject.c:710\n#10 0x00000000004ea437 in PyObject_Repr (v=0x91d650) at Objects/object.c:434\n#11 0x0000000000571932 in builtin_repr (module=\u003coptimized out\u003e, obj=\u003coptimized out\u003e) at Python/bltinmodule.c:2252\n#12 0x00000000004e6c82 in cfunction_vectorcall_O (func=0x9a10f0, args=\u003coptimized out\u003e, nargsf=\u003coptimized out\u003e, kwnames=\u003coptimized out\u003e) at Objects/methodobject.c:514\n#13 0x00000000004a5700 in _PyObject_VectorcallTstate (tstate=0x915430 \u003c_PyRuntime+166000\u003e, callable=callable@entry=0x9a10f0, args=args@entry=0x9a4f98, nargsf=9223372036854775809, \n    kwnames=kwnames@entry=0x0) at ./Include/internal/pycore_call.h:92\n#14 0x00000000004a57cb in PyObject_Vectorcall (callable=callable@entry=0x9a10f0, args=args@entry=0x9a4f98, nargsf=\u003coptimized out\u003e, kwnames=kwnames@entry=0x0) at Objects/call.c:299\n#15 0x0000000000586b4b in _PyEval_EvalFrameDefault (tstate=0x915430 \u003c_PyRuntime+166000\u003e, frame=0x9a4f40, throwflag=\u003coptimized out\u003e) at Python/ceval.c:4765\n#16 0x000000000058af91 in _PyEval_EvalFrame (tstate=tstate@entry=0x915430 \u003c_PyRuntime+166000\u003e, frame=frame@entry=0x9a4f40, throwflag=throwflag@entry=0)\n    at ./Include/internal/pycore_ceval.h:66\n#17 0x000000000058b09c in _PyEval_Vector (tstate=tstate@entry=0x915430 \u003c_PyRuntime+166000\u003e, func=func@entry=0xa41dd0, locals=locals@entry=0xa5ca80, args=args@entry=0x0, \n    argcount=argcount@entry=0, kwnames=kwnames@entry=0x0) at Python/ceval.c:6387\n#18 0x000000000058b190 in PyEval_EvalCode (co=co@entry=0xaa0e70, globals=globals@entry=0xa5ca80, locals=locals@entry=0xa5ca80) at Python/ceval.c:1157\n#19 0x00000000005cb444 in run_eval_code_obj (tstate=tstate@entry=0x915430 \u003c_PyRuntime+166000\u003e, co=co@entry=0xaa0e70, globals=globals@entry=0xa5ca80, locals=locals@entry=0xa5ca80)\n    at Python/pythonrun.c:1713\n#20 0x00000000005cb4fb in run_mod (mod=mod@entry=0xaafda0, filename=filename@entry=0xa8dad0, globals=globals@entry=0xa5ca80, locals=locals@entry=0xa5ca80, flags=flags@entry=0x7fffffffdf08, \n    arena=arena@entry=0xa8dc20) at Python/pythonrun.c:1734\n#21 0x00000000005cb5bf in pyrun_file (fp=fp@entry=0x9c8d20, filename=filename@entry=0xa8dad0, start=start@entry=257, globals=globals@entry=0xa5ca80, locals=locals@entry=0xa5ca80, \n    closeit=closeit@entry=1, flags=0x7fffffffdf08) at Python/pythonrun.c:1629\n#22 0x00000000005cded0 in _PyRun_SimpleFileObject (fp=fp@entry=0x9c8d20, filename=filename@entry=0xa8dad0, closeit=closeit@entry=1, flags=flags@entry=0x7fffffffdf08)\n    at Python/pythonrun.c:439\n#23 0x00000000005ce078 in _PyRun_AnyFileObject (fp=fp@entry=0x9c8d20, filename=filename@entry=0xa8dad0, closeit=closeit@entry=1, flags=flags@entry=0x7fffffffdf08) at Python/pythonrun.c:78\n#24 0x00000000005e9d4b in pymain_run_file_obj (program_name=program_name@entry=0xa02210, filename=filename@entry=0xa8dad0, skip_source_first_line=0) at Modules/main.c:353\n#25 0x00000000005e9e49 in pymain_run_file (config=config@entry=0x8fb490 \u003c_PyRuntime+59600\u003e) at Modules/main.c:372\n#26 0x00000000005ea4e8 in pymain_run_python (exitcode=exitcode@entry=0x7fffffffe05c) at Modules/main.c:592\n#27 0x00000000005ea735 in Py_RunMain () at Modules/main.c:671\n#28 0x00000000005ea78a in pymain_main (args=args@entry=0x7fffffffe0a0) at Modules/main.c:701\n#29 0x00000000005ea80f in Py_BytesMain (argc=\u003coptimized out\u003e, argv=\u003coptimized out\u003e) at Modules/main.c:725\n#30 0x000000000041d70f in main (argc=\u003coptimized out\u003e, argv=\u003coptimized out\u003e) at ./Programs/python.c:15\n```\n\n**Your environment**\n\n- CPython versions tested on: 3.10.4, 3.11.0a7+\n- Operating system and architecture: x86_64\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-136401\n* gh-141993\n* gh-142152\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/hvenev","@type":"Person","name":"hvenev"},"datePublished":"2022-04-17T15:50:57.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":13},"url":"https://github.com/91636/cpython/issues/91636"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:8f45a310-1872-278a-5666-d10da9184c16
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idA524:1D772C:1ACB28B:2385398:696AF707
html-safe-nonce2e0a08ae8e05f00731c25b432fa558cb56192877b8dbbfaa8fc24e04024a6de5
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNTI0OjFENzcyQzoxQUNCMjhCOjIzODUzOTg6Njk2QUY3MDciLCJ2aXNpdG9yX2lkIjoiMjg5MjY1Njc0NzU5MzAwNDgwNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac447c8cc08bcb6d8b8d484ab31b66146bbc01e91d0fe2abf7dad3fd20b1031f0c
hovercard-subject-tagissue:1206414586
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/91636/issue_layout
twitter:imagehttps://opengraph.githubassets.com/8e8d3820afb53b4e18f02d37a0a0258b2ec133aedd8564c15aa5d62ebb369c4c/python/cpython/issues/91636
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/8e8d3820afb53b4e18f02d37a0a0258b2ec133aedd8564c15aa5d62ebb369c4c/python/cpython/issues/91636
og:image:altCrash report It is possible to resurrect a tp_clear-ed object using pure python. The following piece of code illustrates how: import gc, weakref class LateFin: __slots__ = ('ref',) def __del__(self...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamehvenev
hostnamegithub.com
expected-hostnamegithub.com
None5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d
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
release82560a55c6b2054555076f46e683151ee28a19bc
ui-targetcanary-1
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/issues/91636#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F91636
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
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
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
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/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%2F91636
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/91636
Reloadhttps://github.com/python/cpython/issues/91636
Reloadhttps://github.com/python/cpython/issues/91636
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/issues/91636
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 33.9k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 71.1k 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.1k https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects 31 https://github.com/python/cpython/projects
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/python/cpython/security
Please reload this pagehttps://github.com/python/cpython/issues/91636
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 https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/91636
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/91636
Assertion failure when func_repr is called on an already tp_clear-ed objecthttps://github.com/python/cpython/issues/91636#top
3.13bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.13%22
3.14bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.14%22
3.15new features, bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.15%22
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/hvenev
https://github.com/hvenev
hvenevhttps://github.com/hvenev
on Apr 17, 2022https://github.com/python/cpython/issues/91636#issue-1206414586
GH-91636: Clear weakrefs created by finalizers. #136401https://github.com/python/cpython/pull/136401
[3.14] GH-91636: Clear weakrefs created by finalizers. (GH-136401) #141993https://github.com/python/cpython/pull/141993
[3.14] Revert "GH-91636: Clear weakrefs created by finalizers. (GH-136401) (#141993)" #142152https://github.com/python/cpython/pull/142152
3.13bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.13%22
3.14bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.14%22
3.15new features, bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.15%22
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.