sqlite3: pass None for NULL authorizer args instead of crashing (#8534) · RustPython/RustPython@70b47dd · GitHub
Skip to content

Commit 70b47dd

Browse files
authored
sqlite3: pass None for NULL authorizer args instead of crashing (#8534)
* sqlite3: pass None for NULL authorizer args instead of crashing CPython's authorizer callback receives NULL for arg1/arg2/db_name/access when not applicable (e.g. SQLITE_READ on a table gives NULL for the database name in some versions). Previously RustPython passed these pointers to ptr_to_str which would crash or produce an error. Now ptr_to_str_or_none is used: NULL pointers become Python None, which matches CPython behavior and allows test_table_access and test_column_access to pass. Assisted-by: GitHub Copilot:claude-sonnet-4-6 * fix(sqlite3): avoid reentrant deadlock in Statement::new sqlite3_prepare_v2 can synchronously invoke the authorizer callback, which may call back into Connection methods (e.g. set_authorizer) that require the same db lock. Holding db_lock across the prepare() call caused a self-deadlock when a callback re-entered the connection. Release the lock after sql_limit check and copy the raw handle before calling prepare(), so FFI calls that can trigger Python re-entrancy happen outside the lock scope. Fixes hang in test_authorizer_concurrent_mutation_in_call
1 parent 32b1f21 commit 70b47dd

2 files changed

Lines changed: 21 additions & 11 deletions

File tree

Lib/test/test_sqlite3/test_userfunctions.py

Lines changed: 0 additions & 2 deletions

crates/stdlib/src/_sqlite3.rs

Lines changed: 21 additions & 9 deletions

0 commit comments

Comments
 (0)