Commit a151cb6
committed
fix(Session): prevent use-after-free when database is GC'd before session
The Session class was using a raw DatabaseSync* pointer without holding
a reference to keep the database object alive. When JavaScript lost its
reference to the DatabaseSync and GC ran, the database destructor would
be called while Sessions still referenced it, causing SIGSEGV on Alpine
Linux.
Fix: Add Napi::ObjectReference database_ref_ to Session class, matching
the pattern used by StatementSync to prevent the same issue.
Fixes: SIGSEGV in session-lifecycle.test.ts on Alpine Linux (ARM64/x64)1 parent b5835fa commit a151cb6
2 files changed
+14
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2974 | 2974 | | |
2975 | 2975 | | |
2976 | 2976 | | |
| 2977 | + | |
| 2978 | + | |
| 2979 | + | |
| 2980 | + | |
| 2981 | + | |
2977 | 2982 | | |
2978 | 2983 | | |
2979 | 2984 | | |
| |||
2996 | 3001 | | |
2997 | 3002 | | |
2998 | 3003 | | |
| 3004 | + | |
| 3005 | + | |
| 3006 | + | |
| 3007 | + | |
| 3008 | + | |
2999 | 3009 | | |
3000 | 3010 | | |
3001 | 3011 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
360 | 360 | | |
361 | 361 | | |
362 | 362 | | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
363 | 367 | | |
364 | 368 | | |
365 | 369 | | |
| |||
0 commit comments