[New-bugs-announce] [issue42698] Deadlock in pysqlite_connection_dealloc()

hydroflask report at bugs.python.org
Sun Dec 20 19:44:44 EST 2020

New submission from hydroflask <hydroflask at yqxmail.com>:

pysqlite_connection_dealloc() calls sqlite3_close{,_v2}(). This can cause a deadlock if sqlite3_close() tries to acquire a lock that another thread  holds, due to a deadlock between the GIL and an internal sqlite3 lock.

This is especially common with sqlite3's "shared cache mode."

Since the GIL should not be released during a tp_dealloc function and python has no control over the behavior of sqlite3_close(), it is incorrect to call sqlite3_close() in pysqlite_connection_dealloc().

components: Library (Lib)
messages: 383471
nosy: hydroflask
priority: normal
severity: normal
status: open
title: Deadlock in pysqlite_connection_dealloc()
type: behavior
versions: Python 3.10, Python 3.6, Python 3.7, Python 3.8, Python 3.9

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list