Skip to content

gh-156100: Fix crashes in the sqlite3 Connection.autocommit setter - #156104

Merged
serhiy-storchaka merged 3 commits into
python:mainfrom
serhiy-storchaka:gh-156100-sqlite-autocommit-delete
Aug 21, 2026
Merged

serhiy-storchaka merged 3 commits into
python:mainfrom
serhiy-storchaka:gh-156100-sqlite-autocommit-delete

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Aug 20, 2026 •

Copy link
Copy Markdown
Member

The setter passed the deleted value to autocommit_converter(), which dereferences it in Py_IsTrue().
Deleting the attribute now raises AttributeError, like row_factory and text_factory (gh-149738).

autocommit_converter() also reported success with OverflowError set when the value was an integer which does not fit in C long, because PyLong_AsLong() returns -1 on error, and LEGACY_TRANSACTION_CONTROL is -1.
Such value is now rejected with ValueError, like any other invalid value.

The setter passed the deleted value to autocommit_converter(), which
dereferences it.
LEGACY_TRANSACTION_CONTROL is -1, the same value which PyLong_AsLong()
returns on error, so the converter reported success with OverflowError set.
@serhiy-storchaka serhiy-storchaka changed the title gh-156100: Fix a crash when deleting sqlite3 Connection.autocommit Aug 20, 2026
@serhiy-storchaka
serhiy-storchaka merged commit daebcac into python:main Aug 21, 2026
54 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15.
🐍🍒⛏🤖

@serhiy-storchaka
serhiy-storchaka deleted the gh-156100-sqlite-autocommit-delete branch August 21, 2026 07:04
@bedevere-app

bedevere-app Bot commented Aug 21, 2026

Copy link
Copy Markdown

GH-156151 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Aug 21, 2026
@miss-islington-app

Copy link
Copy Markdown

Sorry, @serhiy-storchaka, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker daebcac92d422d7fe9611cbe89044af23ea857c3 3.13
@bedevere-app

bedevere-app Bot commented Aug 21, 2026

Copy link
Copy Markdown

GH-156152 is a backport of this pull request to the 3.14 branch.

@bedevere-app

bedevere-app Bot commented Aug 21, 2026

Copy link
Copy Markdown

GH-156155 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 only security fixes label Aug 21, 2026
serhiy-storchaka added a commit that referenced this pull request Aug 21, 2026
…tter (GH-156104) (GH-156152)

Deleting the attribute crashed, and setting it to an integer which does not
fit in C long reported success with OverflowError set.
(cherry picked from commit daebcac)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
serhiy-storchaka added a commit that referenced this pull request Aug 21, 2026
…tter (GH-156104) (GH-156155)

Deleting the attribute crashed, and setting it to an integer which does not
fit in C long reported success with OverflowError set.

(cherry picked from commit daebcac)
serhiy-storchaka added a commit that referenced this pull request Oct 10, 2026
…tter (GH-156104) (GH-156151)

Deleting the attribute crashed, and setting it to an integer which does not
fit in C long reported success with OverflowError set.
(cherry picked from commit daebcac)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant