Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-127705: better double free message. #130785

Merged
merged 3 commits into from
Mar 5, 2025

Conversation

markshannon
Copy link
Member

@markshannon markshannon commented Mar 3, 2025

Adds a Py_STACKREF_CLOSE_DEBUG #definable option to track closed stack refs. This gives us precise locations for the the initial close and subsequent use or close.

For example, there is a use-after-free in BINARY_OP_INPLACE_ADD_UNICODE (which this PR does not fix)

On main the error message is this:

Fatal Python error: _Py_stackref_record_borrow:
   Invalid StackRef with ID 15618638

With this PR it looks like this:

 Fatal Python error: _Py_stackref_record_borrow: 
   Borrow of closed ref ID 15609203 at Python/generated_cases.c.h:59.
   Referred to instance of str at 0x55a2b6c5ff10. 
   Closed at Python/generated_cases.c.h:344

(I've reformatted the messages for clarity, but the content is unchanged):

@markshannon markshannon merged commit 78d50e9 into python:main Mar 5, 2025
49 checks passed
@markshannon markshannon deleted the better-double-free-message branch March 5, 2025 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants