Commit 0b4ab3f
Harden symbol-dict resource teardown paths
Three defensive fixes on currently-unreachable teardown paths, each
guarding a future edit from a native-memory hazard:
- PersistedSymbolDict.close() now nulls loadedEntriesAddr/Len after
freeing them (like scratchAddr), so a post-close read of the
non-closed-guarded getters cannot dereference freed memory.
- CursorWebSocketSendLoop resets sentDictCount alongside the buffer in
both mirror-free sites, keeping the mirror all-or-nothing. start() has
no closed guard, so a hypothetical close()-then-start() would otherwise
observe a non-zero count against a freed buffer and drive
setWireBaselineWithCatchUp into a null-mirror catch-up.
- PersistedSymbolDict.openFresh() now closes the fd on any throw (the
header malloc moves inside the try, plus a catch), mirroring
openExisting; previously a throw in the header-write body freed the
scratch buffer but leaked the fd.
Tests: testCloseNullsLoadedEntries asserts the getters read 0 after
close; the mirror-leak test now also asserts sentDictCount is reset.
Both fail before their fix.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 8cfd7bd commit 0b4ab3f
4 files changed
Lines changed: 58 additions & 2 deletions
File tree
- core/src
- main/java/io/questdb/client/cutlass/qwp/client/sf/cursor
- test/java/io/questdb/client/test/cutlass/qwp/client/sf/cursor
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
907 | 907 | | |
908 | 908 | | |
909 | 909 | | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
910 | 915 | | |
911 | 916 | | |
912 | 917 | | |
| |||
1793 | 1798 | | |
1794 | 1799 | | |
1795 | 1800 | | |
| 1801 | + | |
1796 | 1802 | | |
1797 | 1803 | | |
1798 | 1804 | | |
| |||
Lines changed: 18 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
282 | 282 | | |
283 | 283 | | |
284 | 284 | | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
285 | 290 | | |
286 | 291 | | |
287 | 292 | | |
| |||
437 | 442 | | |
438 | 443 | | |
439 | 444 | | |
440 | | - | |
| 445 | + | |
441 | 446 | | |
| 447 | + | |
442 | 448 | | |
443 | 449 | | |
444 | 450 | | |
| |||
451 | 457 | | |
452 | 458 | | |
453 | 459 | | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
454 | 468 | | |
455 | | - | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
456 | 472 | | |
457 | 473 | | |
458 | 474 | | |
| |||
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| 92 | + | |
| 93 | + | |
92 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
93 | 101 | | |
94 | 102 | | |
95 | 103 | | |
| |||
Lines changed: 26 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
231 | 257 | | |
232 | 258 | | |
233 | 259 | | |
| |||
0 commit comments