Skip to content

Comments

fix memory corruption when subclassing variable-size types (e.g. abi3 + 3.12 subclassing of native types)#5823

Merged
Icxolu merged 3 commits intoPyO3:mainfrom
davidhewitt:variable-class-subclassing
Feb 17, 2026
Merged

fix memory corruption when subclassing variable-size types (e.g. abi3 + 3.12 subclassing of native types)#5823
Icxolu merged 3 commits intoPyO3:mainfrom
davidhewitt:variable-class-subclassing

Conversation

@davidhewitt
Copy link
Member

This fixes the problem observed in #5807 (comment)

Once we have this merged, we should probably look at releasing 0.28.2 with this fix, given it's memory corruption.

Copy link
Member

@bschoenmaeckers bschoenmaeckers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ngoldbaum
Copy link
Contributor

PyO3's cargo tests fully pass when I merge in this branch to my opaque-pyobject branch from #5807:

nox > Session test was successful in 5 minutes.

This is with the GIL-enabled build. The free-threaded build will take more work. Still - pretty awesome that PyO3 can generate extensions that don't depend on the definition of PyObject on 3.15!

I'm tempted to hit the merge button but given that @Icxolu has been looking at this code recently I'd like them to take a look first.

Copy link
Member

@Icxolu Icxolu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM as well. Thanks for finding the root cause!

@Icxolu Icxolu added this pull request to the merge queue Feb 17, 2026
Merged via the queue into PyO3:main with commit 023eadb Feb 17, 2026
45 checks passed
davidhewitt added a commit that referenced this pull request Feb 17, 2026
…3` + 3.12 subclassing of native types) (#5823)

* add test for subclassing variable-sized type

* fix type confusion inside `get_contents_of_obj`

* newsfragment
@davidhewitt davidhewitt mentioned this pull request Feb 17, 2026
davidhewitt added a commit that referenced this pull request Feb 18, 2026
…3` + 3.12 subclassing of native types) (#5823)

* add test for subclassing variable-sized type

* fix type confusion inside `get_contents_of_obj`

* newsfragment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants