You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
sqlite crashes with converters mutating cursor #80254
cur.execute('create table test(x foo)')
cur.execute('insert into test(x) values (?)', ('foo',))
for row in cur.execute('select x as "x [CURSOR_INIT]", x from test'):
print(row)
Activity
sir-sigurd commentedon Feb 22, 2019
It's somewhat similar to bpo-10811, but for converter function:
In [197]: import sqlite3 as sqlite
...: con = sqlite.connect(':memory:', detect_types=sqlite.PARSE_COLNAMES)
...: cur = con.cursor()
...: sqlite.converters['CURSOR_INIT'] = lambda x: cur.__init__(con)
...:
...: cur.execute('create table test(x foo)')
...: cur.execute('insert into test(x) values (?)', ('foo',))
...: cur.execute('select x as "x [CURSOR_INIT]", x from test')
...:
[1] 25718 segmentation fault python manage.py shell
Similar to bpo-10811, proposed patch raises ProgrammingError instead of crashing.
erlend-aasland commentedon Aug 26, 2021
After #72071 (bpo-44976) there is no longer a segfault.
I suggest to expand the test suite with the reproducer Sergey provided.
erlend-aasland commentedon Aug 26, 2021
Er, a little bit too fast there. There is still a crash, but it is of course postponed bco. bpo-44976. New reproducer:
cur.execute('create table test(x foo)')
cur.execute('insert into test(x) values (?)', ('foo',))
for row in cur.execute('select x as "x [CURSOR_INIT]", x from test'):
print(row)
gh-80254: Disallow recursive usage of cursors in `sqlite3` converters (…
erlend-aasland commentedon May 5, 2022
List of backport PRs:
sqlite3converters #92274sqlite3converters #92278[3.10] gh-80254: Disallow recursive usage of cursors in `sqlite3` con…
[3.9] gh-80254: Disallow recursive usage of cursors in `sqlite3` conv…
[3.8] gh-80254: Disallow recursive usage of cursors in sqlite3 conver…
Python3: update to 3.9.13
[3.7] gh-80254: Disallow recursive usage of cursors in sqlite3 conver…
[3.9] pythongh-80254: Disallow recursive usage of cursors in `sqlite3…