GeezerVison is showing github.com — bpo-42064: Pass module state to `sqlite3` UDF callbacks by erlend-aasland · Pull Request #27456 · python/cpython
Conversation
erlend-aasland
commented
Jul 29, 2021
•
edited by miss-islington
Loading
Uh oh!
There was an error while loading. Please reload this page.
- Establish common callback context struct
- Convert UDF callbacks to fetch module state from callback context
https://bugs.python.org/issue42064
Automerge-Triggered-By: GH:encukou
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
A couple of questions, @encukou:
- Do I need to ensure GIL is held in
create_callback_context(), or can I get away with it like it is?
- Ditto for
free_callback_context()
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Do I need to ensure GIL is held in create_callback_context(), or can I get away with it like it is?
There are very few funcitons in the C-API that you can call without the GIL held; usually they're the ones needed before a GIL is created. For PyMem_Malloc/PyMem_Free specifically, there's a a big red warning to answer your question ;)
PyMem_Malloc is configurable; the default allocator relies on the GIL for synchronization.
|
erlend-aasland reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There are very few funcitons in the C-API that you can call without the GIL held; usually they're the ones needed before a GIL is created. For PyMem_Malloc/PyMem_Free specifically, there's a a big red warning to answer your question ;)
Yes, I've seen it ;) But then why does this PR work as it is? (That is, without the GIL)
(FYI: I'll update the PR with GIL wrappers soon)
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
But then why does this PR work as it is?
I assume it's because you're not using multiple threads.
Even if you were, it might be rare to cause the memory allocator to run in two threads at once. But when it would, it'd crash quite spectacularly. (Or worse, if a malicious actor could cause it to happen.)
|
erlend-aasland reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
But then why does this PR work as it is?
I assume it's because you're not using multiple threads.
Even if you were, it might be rare to cause the memory allocator to run in two threads at once. But when it would, it'd crash quite spectacularly. (Or worse, if a malicious actor could cause it to happen.)
Ah, right. Thanks!
I've updated the PR. PTAL :)
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
On hold until #27613 has landed.
@encukou, this is now ready for review (again). PTAL.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found some more questionable uses of the GIL in existing code (see the issue). But let's not block this PR; it is an improvement.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
erlend-aasland reacted with hooray emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
encukou
encukou approved these changes
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|