Skip to content

bpo-42064: Add module backref to sqlite3 callback context #28242

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 4 commits into from
Oct 19, 2021

Conversation

erlend-aasland
Copy link
Contributor

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

Make sure that the module state will always outlive the callback context
by holding a strong reference to the module object in the callback
context.

https://bugs.python.org/issue42064

@erlend-aasland
Copy link
Contributor Author

FYI, first attempt is in a2d3eae

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

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

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

The AMD64 Arch Linux Asan Debug PR buildbot failure is unrelated to this PR.

@erlend-aasland
Copy link
Contributor Author

erlend-aasland commented Sep 12, 2021

FYI, the windows and asan CI failures are unrelated.

@encukou
Copy link
Member

encukou commented Oct 12, 2021

Whoa, that's certainly a big PR.
Did you consider adding a module pointer to pysqlite_state instead, and increfing/decrefing that? You don't need to store the pointer in the actual struct that "owns" the reference.

@erlend-aasland
Copy link
Contributor Author

erlend-aasland commented Oct 12, 2021

Whoa, that's certainly a big PR.

Did you filter out the auto-generated clinic changes? (You can use the viewed checkbox in GitHub's Files changed PR tab.)

$ git diff main  --stat Modules/_sqlite/*.[ch]
 Modules/_sqlite/connection.c | 55 ++++++++++++++++++++++++++++++++++++++-----------------
 Modules/_sqlite/connection.h |  1 +
 2 files changed, 39 insertions(+), 17 deletions(-)

Copy link
Member

@encukou encukou left a comment

Choose a reason for hiding this comment

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

This looks good, thanks!
One nitpick: it might not be not immediately clear that create_callback_context needs the defining class (i.e. exactly the Connection class, not a subclass which could have a different module). Do you want to add a comment on that?

@erlend-aasland
Copy link
Contributor Author

This looks good, thanks!

Thanks for reviewing :)

One nitpick: it might not be not immediately clear that create_callback_context needs the defining class (i.e. exactly the Connection class, not a subclass which could have a different module). Do you want to add a comment on that?

Yes, that's a good idea.

@erlend-aasland
Copy link
Contributor Author

PTAL

@encukou encukou merged commit 09c04e7 into python:main Oct 19, 2021
@erlend-aasland erlend-aasland deleted the sqlite-callback-ctx-backref branch October 19, 2021 14:38
@bedevere-bot
Copy link

bedevere-bot commented Oct 19, 2021

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 Arch Linux Asan Debug 3.x has failed when building commit 09c04e7.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/585/builds/655) and take a look at the build logs.
  4. Check if the failure is related to this commit (09c04e7) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/585/builds/655

Summary of the results of the build (if available):

Click to see traceback logs
remote: Enumerating objects: 8, done.        
remote: Counting objects:  12% (1/8)        
remote: Counting objects:  25% (2/8)        
remote: Counting objects:  37% (3/8)        
remote: Counting objects:  50% (4/8)        
remote: Counting objects:  62% (5/8)        
remote: Counting objects:  75% (6/8)        
remote: Counting objects:  87% (7/8)        
remote: Counting objects: 100% (8/8)        
remote: Counting objects: 100% (8/8), done.        
remote: Compressing objects:  12% (1/8)        
remote: Compressing objects:  25% (2/8)        
remote: Compressing objects:  37% (3/8)        
remote: Compressing objects:  50% (4/8)        
remote: Compressing objects:  62% (5/8)        
remote: Compressing objects:  75% (6/8)        
remote: Compressing objects:  87% (7/8)        
remote: Compressing objects: 100% (8/8)        
remote: Compressing objects: 100% (8/8), done.        
remote: Total 8 (delta 0), reused 1 (delta 0), pack-reused 0        
From https://github.com/python/cpython
 * branch                  main       -> FETCH_HEAD
Note: switching to '09c04e7f0d26f0006964554b6a0caa5ef7f0bd24'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 09c04e7f0d [bpo-42064](https://bugs.python.org/issue42064): Add module backref to `sqlite3` callback context (GH-28242)
Switched to and reset branch 'main'

renaming build/scripts-3.11/pydoc3 to build/scripts-3.11/pydoc3.11
renaming build/scripts-3.11/idle3 to build/scripts-3.11/idle3.11
renaming build/scripts-3.11/2to3 to build/scripts-3.11/2to3-3.11

renaming build/scripts-3.11/pydoc3 to build/scripts-3.11/pydoc3.11
renaming build/scripts-3.11/idle3 to build/scripts-3.11/idle3.11
renaming build/scripts-3.11/2to3 to build/scripts-3.11/2to3-3.11

renaming build/scripts-3.11/pydoc3 to build/scripts-3.11/pydoc3.11
renaming build/scripts-3.11/idle3 to build/scripts-3.11/idle3.11
renaming build/scripts-3.11/2to3 to build/scripts-3.11/2to3-3.11
make: *** [Makefile:1352: buildbottest] Terminated

Cannot open file '/buildbot/buildarea/3.x.pablogsal-arch-x86_64.asan_debug/build/test-results.xml' for upload

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.

4 participants