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

hold onto module name properly in PyCFunction::internal_new #3649

Merged
merged 1 commit into from
Dec 14, 2023

Conversation

davidhewitt
Copy link
Member

While going through the rewrites in #3606, I spotted that there's a slight "oops" in PyCFunction::internal_new where we do basically m.name()?.into_py(py).as_ptr() to create a dangling pointer. We get away with this at present because .into_py(py) uses PyString::new and puts the string into the GIL pool, thus despite the dangling pointer the reference count is still one for the duration we need it.

One the pool bandaid comes off, this bit of code segfaults.

Opened as a review separately because I think this is trivially reviewable and mergeable.

@davidhewitt davidhewitt added the CI-skip-changelog Skip checking changelog entry label Dec 14, 2023
@davidhewitt davidhewitt changed the title hold onto module name properly in PyCfunction::internal_new hold onto module name properly in PyCFunction::internal_new Dec 14, 2023
Copy link
Member

@adamreichold adamreichold left a comment

Choose a reason for hiding this comment

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

Great catch!

@adamreichold adamreichold added this pull request to the merge queue Dec 14, 2023
Merged via the queue into PyO3:main with commit 763ecb3 Dec 14, 2023
36 of 37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI-skip-changelog Skip checking changelog entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants