summaryrefslogtreecommitdiff
path: root/Modules/_sqlite/connection.c
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2021-06-05 16:13:27 -0700
committerGitHub <noreply@github.com>2021-06-06 00:13:27 +0100
commit317e9ed4363a86b1364573c5a5e30011a080ce6d (patch)
tree4ff879b6bbf83fe0c6388d2972e43f8b9ade7427 /Modules/_sqlite/connection.c
parentad2f3b74b5615aa36a82d1fdbc45bb7468aa1d72 (diff)
downloadcpython-git-317e9ed4363a86b1364573c5a5e30011a080ce6d.tar.gz
bpo-44304: Ensure the sqlite3 destructor callback is always called with the GIL held (GH-26551) (GH_26552)
(cherry picked from commit 6e3b7cf3af3ed7758b2c2193c1d393feb8ab8f72) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
Diffstat (limited to 'Modules/_sqlite/connection.c')
-rw-r--r--Modules/_sqlite/connection.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c
index fccffabc4b..8e42a36bd3 100644
--- a/Modules/_sqlite/connection.c
+++ b/Modules/_sqlite/connection.c
@@ -851,7 +851,12 @@ static void _pysqlite_drop_unused_cursor_references(pysqlite_Connection* self)
static void _destructor(void* args)
{
+ // This function may be called without the GIL held, so we need to ensure
+ // that we destroy 'args' with the GIL
+ PyGILState_STATE gstate;
+ gstate = PyGILState_Ensure();
Py_DECREF((PyObject*)args);
+ PyGILState_Release(gstate);
}
/*[clinic input]