Commit 8741c06
committed
Add regression tests for exqlite_close, last_insert_rowid, transaction_status
Each test targets a distinct race condition or NULL-deref in sqlite3_nif.c
and was confirmed to crash with SIGSEGV (exit 139) on the unfixed NIF.
1. "concurrent double close" — TOCTOU in exqlite_close: two threads both
pass the `conn->db == NULL` check outside the lock; one closes the db
and NULLs the pointer; the second then calls
sqlite3_get_autocommit(NULL) inside the lock → crash.
2. "last_insert_rowid after close" — missing NULL guard in
exqlite_last_insert_rowid: acquires the lock but calls
sqlite3_last_insert_rowid(conn->db) without checking for NULL;
deterministic crash after a sequential close().
3. "concurrent close and transaction_status" — TOCTOU in
exqlite_transaction_status: !conn->db is checked outside the lock,
sqlite3_get_autocommit(conn->db) is called inside it; concurrent
close() can free conn->db between them → crash.1 parent 66185e1 commit 8741c06
1 file changed
Lines changed: 54 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
844 | 844 | | |
845 | 845 | | |
846 | 846 | | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
847 | 901 | | |
848 | 902 | | |
0 commit comments