Commit 70b47dd
authored
sqlite3: pass None for NULL authorizer args instead of crashing (RustPython#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_call1 parent 32b1f21 commit 70b47dd
2 files changed
Lines changed: 21 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
800 | 800 | | |
801 | 801 | | |
802 | 802 | | |
803 | | - | |
804 | 803 | | |
805 | 804 | | |
806 | 805 | | |
807 | 806 | | |
808 | 807 | | |
809 | | - | |
810 | 808 | | |
811 | 809 | | |
812 | 810 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
587 | 587 | | |
588 | 588 | | |
589 | 589 | | |
590 | | - | |
591 | | - | |
592 | | - | |
593 | | - | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
594 | 594 | | |
595 | 595 | | |
596 | 596 | | |
| |||
2842 | 2842 | | |
2843 | 2843 | | |
2844 | 2844 | | |
2845 | | - | |
2846 | | - | |
2847 | | - | |
| 2845 | + | |
| 2846 | + | |
| 2847 | + | |
| 2848 | + | |
| 2849 | + | |
2848 | 2850 | | |
2849 | 2851 | | |
2850 | | - | |
| 2852 | + | |
2851 | 2853 | | |
2852 | 2854 | | |
2853 | 2855 | | |
| |||
3540 | 3542 | | |
3541 | 3543 | | |
3542 | 3544 | | |
3543 | | - | |
| 3545 | + | |
| 3546 | + | |
| 3547 | + | |
| 3548 | + | |
| 3549 | + | |
| 3550 | + | |
| 3551 | + | |
| 3552 | + | |
| 3553 | + | |
| 3554 | + | |
| 3555 | + | |
3544 | 3556 | | |
3545 | 3557 | | |
3546 | 3558 | | |
| |||
0 commit comments