diff options
author | Pablo Galindo <Pablogsal@gmail.com> | 2021-06-05 22:41:11 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-05 22:41:11 (GMT) |
commit | 6e3b7cf3af3ed7758b2c2193c1d393feb8ab8f72 (patch) | |
tree | 68a00d502cf1f0cbdd4a7f2b105eb7a699d87436 /Modules/_sqlite | |
parent | fa106a685c1f199aca5be5c2d0277a14cc9057bd (diff) | |
download | cpython-6e3b7cf3af3ed7758b2c2193c1d393feb8ab8f72.zip cpython-6e3b7cf3af3ed7758b2c2193c1d393feb8ab8f72.tar.gz cpython-6e3b7cf3af3ed7758b2c2193c1d393feb8ab8f72.tar.bz2 |
bpo-44304: Ensure the sqlite3 destructor callback is always called with the GIL held (GH-26551)
Diffstat (limited to 'Modules/_sqlite')
-rw-r--r-- | Modules/_sqlite/connection.c | 5 | ||||
-rw-r--r-- | Modules/_sqlite/statement.c | 2 |
2 files changed, 7 insertions, 0 deletions
diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c index c2f3bc0..fbee1b7 100644 --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -825,7 +825,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] diff --git a/Modules/_sqlite/statement.c b/Modules/_sqlite/statement.c index c9dd882..f12ef67 100644 --- a/Modules/_sqlite/statement.c +++ b/Modules/_sqlite/statement.c @@ -404,7 +404,9 @@ stmt_dealloc(pysqlite_Statement *self) PyObject_ClearWeakRefs((PyObject*)self); } if (self->st) { + Py_BEGIN_ALLOW_THREADS sqlite3_finalize(self->st); + Py_END_ALLOW_THREADS self->st = 0; } tp->tp_clear((PyObject *)self); |