René's URL Explorer Experiment


Title: gh-151763: Fix double decref in _PyPegen_raise_error_known_location() by manoj-marimuthu · Pull Request #151931 · python/cpython · GitHub

Open Graph Title: gh-151763: Fix double decref in _PyPegen_raise_error_known_location() by manoj-marimuthu · Pull Request #151931 · python/cpython

X Title: gh-151763: Fix double decref in _PyPegen_raise_error_known_location() by manoj-marimuthu · Pull Request #151931 · python/cpython

Description: The following PR addresses OOM-00019 from issue-151763. Issue: The _PyPegen_raise_error_known_location() in pegen_errors.c uses the Py_BuildValue function on a PyObject* called error_line with reference-stealing N format. tmp = Py_BuildValue("(OnnNnn)", p->tok->filename, lineno, col_number, error_line, end_lineno, end_col_number); when Py_BuildValue fails it returns NULL (ie tmp becomes NULL). when tmp == NULL, we do: if (!tmp) { goto error; } and goto error does: error: Py_XDECREF(errstr); Py_XDECREF(error_line); return NULL; This means that even if Py_BuildValue has decref'd error_line already, goto error repeats it which in turn trips _Py_NegativeRefcount: on debug builds. Reproduced using: import ast, _testcapi, faulthandler faulthandler.enable() src = "x y z\n" # generic invalid syntax -> located SyntaxError _testcapi.set_nomemory(55, 0) # fail every allocation from #55 onward try: ast.parse(src) # error_line built OK, then Py_BuildValue fails # -> N-arg already consumed -> error: decrefs it again finally: _testcapi.remove_mem_hooks() In debug build (tested on windows), it gives: _Py_NegativeRefcount: Assertion failed: object has negative ref count Fatal Python error: _PyObject_AssertFailed: _PyObject_AssertFailed Python runtime state: initialized object address : 000001FC9931C4B0 object refcount : 1 object type : 00007FF875688D10 object type name: MemoryError object repr : lost sys.stderr Current thread 0x00003d48 (most recent call first): File "D:\open source\cpython\Lib\ast.py", line 46 in parse File "D:\open source\cpython\PCBuild\amd64\reproducer.py", line 6 in Extension modules: _testcapi (total: 1) Fix we can fix this by setting error_line to NULL just after tmp's declaration so that Py_XDECREF(error_line); neglects it when Py_BuildValue() fails. error_line = NULL; It now raises a MemoryError correctly. Tested on - windows branch - 3.16.0a0 Issue: gh-151763

Open Graph Description: The following PR addresses OOM-00019 from issue-151763. Issue: The _PyPegen_raise_error_known_location() in pegen_errors.c uses the Py_BuildValue function on a PyObject* called error_line with refe...

X Description: The following PR addresses OOM-00019 from issue-151763. Issue: The _PyPegen_raise_error_known_location() in pegen_errors.c uses the Py_BuildValue function on a PyObject* called error_line with refe...

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

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:25edb22e-ee50-8d76-bfaa-ae1c7c8e5ff4
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id901A:202447:4EC36:6D87A:6A535FAC
html-safe-nonceaa77dd066190482e38334ab03af09c61645d5acbff3d7b9241040b30af6b7408
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MDFBOjIwMjQ0Nzo0RUMzNjo2RDg3QTo2QTUzNUZBQyIsInZpc2l0b3JfaWQiOiIzODMzMDAzMDU0OTY3NTEzMDA0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmaca6b5136544afb33a23e70bfb50ae09090565a03b361d2ec59bf9573152553f91
hovercard-subject-tagpull_request:3913829528
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python/cpython/pull/151931/files
twitter:imagehttps://avatars.githubusercontent.com/u/286359136?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/286359136?s=400&v=4
og:image:altThe following PR addresses OOM-00019 from issue-151763. Issue: The _PyPegen_raise_error_known_location() in pegen_errors.c uses the Py_BuildValue function on a PyObject* called error_line with refe...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Noneb9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb
turbo-cache-controlno-preview
diff-viewunified
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-turbotrue
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/pull/151931/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F151931%2Ffiles
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%2Fpull%2F151931%2Ffiles
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%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/pull/151931/files
Reloadhttps://github.com/python/cpython/pull/151931/files
Reloadhttps://github.com/python/cpython/pull/151931/files
Please reload this pagehttps://github.com/python/cpython/pull/151931/files
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/pull/151931/files
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
Sign up for GitHub https://github.com/signup?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
manoj-marimuthuhttps://github.com/manoj-marimuthu
python:mainhttps://github.com/python/cpython/tree/main
manoj-marimuthu:fix-double-decrefhttps://github.com/manoj-marimuthu/cpython/tree/fix-double-decref
Conversation 1 https://github.com/python/cpython/pull/151931
Commits 4 https://github.com/python/cpython/pull/151931/commits
Checks 49 https://github.com/python/cpython/pull/151931/checks
Files changed 1 https://github.com/python/cpython/pull/151931/files
gh-151763: Fix double decref in _PyPegen_raise_error_known_location() https://github.com/python/cpython/pull/151931/files#top
Show all changes 4 commits https://github.com/python/cpython/pull/151931/files
7ab6125 Fix double free in _PyPegen_raise_error_known_location() manoj-marimuthu Jun 22, 2026 https://github.com/python/cpython/pull/151931/commits/7ab6125783f7ae70b2d90f1bc21e8122678131f6
7fa8e4f Highlight MemoryError in News entry manoj-marimuthu Jun 22, 2026 https://github.com/python/cpython/pull/151931/commits/7fa8e4fae8d4165892c5aad2912edd0f177d3f50
796c51b Remove news entry manoj-marimuthu Jun 23, 2026 https://github.com/python/cpython/pull/151931/commits/796c51b7adf2d29bfaef0644bdec614dce525398
d702f01 Merge branch 'main' into fix-double-decref manoj-marimuthu Jun 23, 2026 https://github.com/python/cpython/pull/151931/commits/d702f01a308049a9ce8bbbc25584d8ca7ffbc35f
Clear filters https://github.com/python/cpython/pull/151931/files
Please reload this pagehttps://github.com/python/cpython/pull/151931/files
Please reload this pagehttps://github.com/python/cpython/pull/151931/files
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L315
Parser/pegen_errors.chttps://github.com/python/cpython/pull/151931/files#diff-f15d7b3d0bc84baf512dd165bea4e2e1dddb1fe33f836ee08b811621df3260cb
View file https://github.com/python/cpython/blob/d702f01a308049a9ce8bbbc25584d8ca7ffbc35f/Parser/pegen_errors.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/151931/{{ revealButtonHref }}
https://github.com/python/cpython/pull/151931/files#diff-f15d7b3d0bc84baf512dd165bea4e2e1dddb1fe33f836ee08b811621df3260cb
https://github.com/python/cpython/pull/151931/files#diff-f15d7b3d0bc84baf512dd165bea4e2e1dddb1fe33f836ee08b811621df3260cb
Please reload this pagehttps://github.com/python/cpython/pull/151931/files
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.