Skip to content

bpo-45126: Fix ref. leak in sqlite3.Connection.__init__ #28231

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

Merged
merged 2 commits into from
Sep 12, 2021

Conversation

erlend-aasland
Copy link
Contributor

@erlend-aasland erlend-aasland commented Sep 8, 2021

'database_obj' no longer leaks if audit fails.

  • Let AC handle full conversion of 'database' arg, from pathlike object to C string
  • Let AC handle resource management of 'database' arg

Resolves #89289

https://bugs.python.org/issue45126

@erlend-aasland
Copy link
Contributor Author

erlend-aasland commented Sep 8, 2021

Although this could be fixed by a decref after the audit check, it is not immediately clear why only database_obj needs special treatment, and not the other arguments. Taking resource management out of __init__ and placing it in AC is IMO a cleaner approach.

@erlend-aasland erlend-aasland added needs backport to 3.10 only security fixes needs backport to 3.9 only security fixes 🔨 test-with-buildbots Test PR w/ buildbots; report in status section labels Sep 8, 2021
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @erlend-aasland for commit c1f8b43 🤖

If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Sep 8, 2021
@erlend-aasland
Copy link
Contributor Author

erlend-aasland commented Sep 9, 2021

  • test_multiprocessing_spawn failed on the PPC64LE RHEL8 Refleaks PR buildbot; test_sqlite passed.
  • the AMD64 Arch Linux Asan Debug PR buildbot failure is unrelated to this PR

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

And if you don't make the requested changes, you will be poked with soft cushions!

Co-authored-by: Dong-hee Na <[email protected]>
@erlend-aasland
Copy link
Contributor Author

I have made the requested changes; please review again

@bedevere-bot
Copy link

Thanks for making the requested changes!

@corona10: please review the changes made to this pull request.

@corona10 corona10 added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Sep 12, 2021
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @corona10 for commit 9d247e1 🤖

If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Sep 12, 2021
Copy link
Member

@corona10 corona10 left a comment

Choose a reason for hiding this comment

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

lgtm
Failed CIs doesn't look related to change.

@corona10 corona10 merged commit c78d5ca into python:main Sep 12, 2021
@miss-islington
Copy link
Contributor

Thanks @erlend-aasland for the PR, and @corona10 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9, 3.10.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Sorry, @erlend-aasland and @corona10, I could not cleanly backport this to 3.10 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker c78d5ca3806d02e26f9f3fa92ff567f0805eac4c 3.10

@miss-islington
Copy link
Contributor

Sorry @erlend-aasland and @corona10, I had trouble checking out the 3.9 backport branch.
Please backport using cherry_picker on command line.
cherry_picker c78d5ca3806d02e26f9f3fa92ff567f0805eac4c 3.9

@corona10
Copy link
Member

@erlend-aasland Cherry-pick please.

@erlend-aasland erlend-aasland deleted the sqlite-ref-leak-con-init branch September 12, 2021 12:29
@erlend-aasland
Copy link
Contributor Author

@erlend-aasland Cherry-pick please.

I'll fix the backports. Thank you so much for reviewing. Highly appreciated.

erlend-aasland pushed a commit to erlend-aasland/cpython that referenced this pull request Sep 12, 2021
…honGH-28231).

(cherry picked from commit c78d5ca)

Co-authored-by: Erlend Egeberg Aasland <[email protected]>
@bedevere-bot
Copy link

GH-28298 is a backport of this pull request to the 3.10 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.10 only security fixes label Sep 12, 2021
@erlend-aasland erlend-aasland removed the needs backport to 3.9 only security fixes label Sep 12, 2021
@erlend-aasland
Copy link
Contributor Author

We backport to 3.9 from GH-28298.

erlend-aasland pushed a commit to erlend-aasland/cpython that referenced this pull request Sep 12, 2021
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 13, 2021
miss-islington added a commit that referenced this pull request Sep 13, 2021
…28231). (GH-28298)

(cherry picked from commit aa6dd54)

Co-authored-by: Erlend Egeberg Aasland <[email protected]>
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.

[sqlite3] cleanup and harden Connection.__init__
5 participants