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
### Bug 2d: Double-Free in DeleteAllSessions During GC
93
+
94
+
**The bug**: `DeleteAllSessions()` interleaved SQLite cleanup and `database_ref_.Reset()` calls in a single loop. When `Reset()` triggers GC, other Session objects in the iteration list may be finalized, causing their destructors to call `sqlite3session_delete()` on sessions that the loop will later process.
95
+
96
+
**How it manifested**:
97
+
98
+
1.`DeleteAllSessions()` iterates over `sessions_copy`
99
+
2. For session X: `sqlite3session_delete(X)`, `X->session_ = nullptr`, `X->database_ref_.Reset()`
100
+
3.`Reset()` triggers GC which finalizes session Y (also in `sessions_copy`, not yet processed)
101
+
4. Y's destructor calls `Delete()` → `sqlite3session_delete(Y->session_)` (Y's session_ is still valid!)
102
+
5. Loop continues to Y → calls `sqlite3session_delete(Y)` again → **double-free → SIGABRT**
103
+
104
+
**Fix**: Split cleanup into two passes:
105
+
1. Pass 1: Delete all SQLite sessions and clear all `session_` pointers
106
+
2. Pass 2: Release database references (can trigger GC, but Delete() is now a no-op for all sessions)
0 commit comments