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

bpo-40645: Fix reference leak in the _hashopenssl extension #26072

Merged
merged 1 commit into from
May 12, 2021

Conversation

encukou
Copy link
Member

@encukou encukou commented May 12, 2021

The PyModule_AddObjectRef function doesn't steal a reference, so an extra Py_DECREF is needed.

https://bugs.python.org/issue40645

Automerge-Triggered-By: GH:tiran

The PyModule_AddObjectRef function doesn't steal a reference,
so an extra Py_DECREF is needed.
@tiran
Copy link
Member

tiran commented May 12, 2021

Thank you!

@erlend-aasland
Copy link
Contributor

erlend-aasland commented May 12, 2021

There's also three leaks in the preceding for-loop:name_obj and func => fixed in 26079

Comment on lines 2109 to +2112
if (PyModule_AddObjectRef(module, "_constructors", proxy) < 0) {
return -1;
}
Py_DECREF(proxy);
Copy link
Contributor

Choose a reason for hiding this comment

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

Decref in case PyModule_AddObjectRef fails, no?

Suggested change
if (PyModule_AddObjectRef(module, "_constructors", proxy) < 0) {
return -1;
}
Py_DECREF(proxy);
int rc = PyModule_AddObjectRef(module, "_constructors", proxy);
Py_DECREF(proxy);
if (rc < 0) {
return -1;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

FYI, fixed in #26079

@miss-islington
Copy link
Contributor

@encukou: Status check is done, and it's a success ✅ .

@miss-islington miss-islington merged commit 3611db5 into python:main May 12, 2021
@miss-islington
Copy link
Contributor

Thanks @encukou for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Sorry @encukou, I had trouble checking out the 3.10 backport branch.
Please backport using cherry_picker on command line.
cherry_picker 3611db53f5b854cb6d01ee5ebb5e11c87bcc2df5 3.10

@Mariatta
Copy link
Member

Mariatta commented Jun 2, 2021

Does this still need backport to 3.10?

@erlend-aasland
Copy link
Contributor

Does this still need backport to 3.10?

I believe so, yes.

cc @pablogsal.

@pablogsal
Copy link
Member

Does this still need backport to 3.10?

I believe so, yes.

cc @pablogsal.

This indeed need to be backported

@erlend-aasland
Copy link
Contributor

I can create a backport of this together with a backport of #26079, @pablogsal. Let me know if that's ok with you, @encukou.

@encukou
Copy link
Member Author

encukou commented Jun 4, 2021

It is. Thank you!

@encukou encukou deleted the hashlib-refleak branch June 4, 2021 08:00
@erlend-aasland
Copy link
Contributor

Oh, I already did this in #26082 :) Backport is done; no further actions needed.

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.

8 participants