Commit dadbb86
committed
fix(Session): avoid mutex deadlock in DeleteAllSessions
Calling database_ref_.Reset() can trigger GC, which can finalize other
Session objects. Those Session destructors call Delete() -> RemoveSession()
which tries to lock sessions_mutex_. Since std::mutex is not recursive,
holding the lock during Reset() causes undefined behavior (SIGSEGV on
Alpine/musl).
Fix: Release the mutex before iterating. Since sessions_ is cleared first,
any RemoveSession() calls during GC become no-ops (erasing from empty set).1 parent fb283df commit dadbb86
1 file changed
+13
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1514 | 1514 | | |
1515 | 1515 | | |
1516 | 1516 | | |
1517 | | - | |
1518 | | - | |
1519 | | - | |
1520 | | - | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + | |
| 1520 | + | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
1521 | 1528 | | |
1522 | | - | |
| 1529 | + | |
1523 | 1530 | | |
1524 | 1531 | | |
1525 | 1532 | | |
| |||
1531 | 1538 | | |
1532 | 1539 | | |
1533 | 1540 | | |
| 1541 | + | |
1534 | 1542 | | |
1535 | 1543 | | |
1536 | 1544 | | |
| |||
0 commit comments