Repository navigation
deleting sqlite3 row_factory causes segfault #149738
Description
Activity
- addedtype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
on May 12, 2026 Hi @lunixbochs, thanks for the clear report!
I can work on a fix for this if nobody is already doing so.
It may also make sense to add thetopic-sqlite3andstdliblabels.- addedextension-modulesC modules in the Modules dirC modules in the Modules dir
on May 12, 2026 Hi @lunixbochs, thanks for the clear report!
I can work on a fix for this if nobody is already doing so.
It may also make sense to add thetopic-sqlite3andstdliblabels.Sure! I don't think anyone is actively working on it, feel free to to correct me if I'm wrong :)
Reacted by Sepehr Rasouli- added a commit that references this issue
on Jun 2, 2026 With the fix, the example now fails with:
Traceback (most recent call last): File "/home/vstinner/python/main/x.py", line 3, in <module> del db.row_factory ^^^^^^^^^^^^^^ AttributeError: cannot delete row_factory attributeIs there any reasonable user code that gets this error, and without the fix it didn't segfault [edit: or raise] later?
Is there any reasonable user code that gets this error, and without the fix it didn't segfault later?
I don't think that it's possible to do anything useful without
row_factoryortext_factoryattribute.After
del db.row_factory, anydb.execute()call does crash. So it makes the connection unusable.For
text_factory, any request returning a text column does fail with an internal error (SystemError):import sqlite3 db = sqlite3.connect(":memory:") del db.text_factory row = db.execute("SELECT 'a'") print(row.fetchone())
Output without this fix:
Traceback (most recent call last): File "/home/vstinner/python/main/x.py", line 5, in <module> print(row.fetchone()) ~~~~~~~~~~~~^^ SystemError: null argument to internal routineReacted by Petr Viktorin- added a commit that references this issue
on Aug 21, 2026
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsDone
Crash report
What happened?
->
zsh: segmentation fault python3In connection.c, the row_factory is compared against Py_None and incref'd, but deleting it sets it to null, resulting in
Py_INCREF(NULL)CPython versions tested on:
3.14
Operating systems tested on:
macOS
Output from running 'python -VV' on the command line:
No response
Linked PRs