Skip to content

fix lifetime of return value in PyClassGuardMutSuper::as_super#6181

Merged
Icxolu merged 2 commits into
PyO3:mainfrom
davidhewitt:as-super-lifetime
Jul 2, 2026
Merged

fix lifetime of return value in PyClassGuardMutSuper::as_super#6181
Icxolu merged 2 commits into
PyO3:mainfrom
davidhewitt:as-super-lifetime

Conversation

@davidhewitt

@davidhewitt davidhewitt commented Jul 2, 2026

Copy link
Copy Markdown
Member

PyClassGuardMutSuper::as_super was incorrectly returning a super-guard with lifetime 'a decoupled from the &mut borrow of the guard. This allows the super-guard to exist after the .as_super() borrow ends, potentially leading to mutable aliasing issues.

cc @Icxolu - we missed this in #6104

(Credit to Codex security scanning for this discovery.)

@davidhewitt

davidhewitt commented Jul 2, 2026

Copy link
Copy Markdown
Member Author

I'm torn whether to ship this in 0.29.1. In theory it could break builds, but it seems like anyone who would be broken by this potentially has issues anyway. (So I think my leaning is that it's better to ship it.)

I don't think it's bad enough to warrant yanking 0.29.0.

@Icxolu Icxolu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah, in hindsight this is quite clearly wrong 🙈. I agree that we should ship in 0.29.1. If this breaks someone, that code is also clearly wrong. Also we have not yet really advertised this type much and not introduced a direct way to borrow a guard, only via extract, so I doubt there will be many uses already.

@Icxolu Icxolu enabled auto-merge July 2, 2026 19:37
@Icxolu Icxolu added this pull request to the merge queue Jul 2, 2026
Merged via the queue into PyO3:main with commit 87dc97c Jul 2, 2026
49 of 50 checks passed
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.

2 participants