Skip to content

bpo-42972: Fully implement GC protocol for sqlite3 heap types #26104

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 14 commits into from
May 25, 2021

Conversation

erlend-aasland
Copy link
Contributor

@erlend-aasland erlend-aasland commented May 13, 2021

@erlend-aasland
Copy link
Contributor Author

@pablogsal May I add skip news for this PR?

@erlend-aasland
Copy link
Contributor Author

erlend-aasland commented May 13, 2021

@pablogsal:

  • I've added tp_clear functions to (almost) all types, since it is recommended by both the doc's and the dev guide. (It also improves readability, IMO.)
  • In the tp_clear functions, I've converted Py_(X)DECREF's to Py_CLEAR. It that a problem for objects where we know multiple objects have strong refs. to them?
  • Can I normalise the naming for the dealloc functions (=> drop the pysqlite_ prefix)?
  • I've added Py_VISIT's for all containers and objects that are passed to us from "Py space"

@erlend-aasland erlend-aasland changed the title bpo-42972: implement full GC support for sqlite3 heap types bpo-42972: Fully implement GC protocol for sqlite3 heap types May 14, 2021
@erlend-aasland erlend-aasland added the needs backport to 3.10 only security fixes label May 14, 2021
@pablogsal
Copy link
Member

Will review this as soon as possible, but ping me if I haven't done this week :)

@erlend-aasland
Copy link
Contributor Author

Will review this as soon as possible, but ping me if I haven't done this week :)

No stress; I'm trying to figure out a way to reliably test this :)

@pablogsal
Copy link
Member

  • In the tp_clear functions, I've converted Py_(X)DECREF's to Py_CLEAR. It that a problem for objects where we know multiple objects have strong refs. to them?

Not sure I understand the question correctly, but in general Py_CLEAR is always better. It is the recommended and safe way to clear data attributes of arbitrary types while decrementing their reference counts. If you were to call Py_XDECREF() instead on the attribute before setting it to NULL, there is a possibility that the attribute’s destructor would call back into code that reads the attribute again (especially if there is a reference cycle).

  • Can I normalise the naming for the dealloc functions (=> drop the pysqlite_ prefix)?

Go ahead!

  • I've added Py_VISIT's for all containers and objects that are passed to us from "Py space"

👍

@erlend-aasland
Copy link
Contributor Author

Not sure I understand the question correctly, but in general Py_CLEAR is always better.

No worries, I was mixing up some ref. count concepts. You can disregard that question :)

@erlend-aasland
Copy link
Contributor Author

@pablogsal Would you mind reviewing the changes? I cannot come up with a way to reliably test this; I guess that would have been easier if sqlite3 had a module state and used multi-phase init (long way to get there).

@pablogsal
Copy link
Member

Can you also make a refleak run?

@erlend-aasland
Copy link
Contributor Author

erlend-aasland commented May 25, 2021

Can you also make a refleak run?

Yep! That's a normal buildbot run, right, or did you have something else in mind? I've already done a test -R : run locally. @pablogsal

@pablogsal
Copy link
Member

Thanks a lot for the patience @erlend-aasland, this is very close to be ready for lending. The GC changes are always tricky so we need to be sure to get them right :)

@erlend-aasland
Copy link
Contributor Author

Thanks a lot for the patience @erlend-aasland, this is very close to be ready for lending. The GC changes are always tricky so we need to be sure to get them right :)

No problem, I fully agree :)

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

🤖 New build scheduled with the buildbot fleet by @pablogsal for commit 926787d 🤖

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 May 25, 2021
Copy link
Member

@pablogsal pablogsal left a comment

Choose a reason for hiding this comment

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

LGTM

Great job!

@pablogsal pablogsal merged commit d3c277a into python:main May 25, 2021
@miss-islington
Copy link
Contributor

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

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 25, 2021
…GH-26104)

(cherry picked from commit d3c277a)

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

GH-26361 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 May 25, 2021
@erlend-aasland
Copy link
Contributor Author

Great job!

Fantastic, thank you so much for helping out!

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.

6 participants