fix: pyo3_ffi's PyObject_GET_WEAKREFS_LISTPTR and PyHeapType_GET_MEMBERS fail with address sanitizer#6145
Open
IvanIsCoding wants to merge 5 commits into
Open
fix: pyo3_ffi's PyObject_GET_WEAKREFS_LISTPTR and PyHeapType_GET_MEMBERS fail with address sanitizer#6145IvanIsCoding wants to merge 5 commits into
pyo3_ffi's PyObject_GET_WEAKREFS_LISTPTR and PyHeapType_GET_MEMBERS fail with address sanitizer#6145IvanIsCoding wants to merge 5 commits into
Conversation
Member
|
@davidhewitt I think this one was one of the claude findings, does that sound right? |
alex
approved these changes
Jun 20, 2026
alex
left a comment
Member
There was a problem hiding this comment.
the code itself looks correct. I feel like either we should have a test, or we should just delete this binding if we're not using it though.
Contributor
Author
With regards to correctness: https://github.com/dgrunwald/rust-cpython/blob/a60f149f2f64be2d533cf72364fdaeaa8b08893f/python3-sys/src/objimpl.rs#L131 I think the (ancient) version pre-fork had a correct implementation, so somewhere along the way the bug was introduced. It does look that usage is extremely low, so feel free to remove the code. I couldn't find a single call by PyO3 itself and the GitHub search points more to PyO3 forks than real users. |
mejrs
reviewed
Jun 20, 2026
mejrs
approved these changes
Jun 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to #5916
This small module:
Fails unit tests when running with an address sanitizer:
Comparing with the implementation in C, this bug happens when
size_of::<PyHeapTypeObject>()is not1.The initial finding was made by @Manishearth when checking
unsafecode blocks (using LLMs)