Commit 588ba3f
fix(btree): resolve all 8 Valgrind memcheck defects in BTreeTest
Valgrind (ctest -T memcheck) reported 8 error contexts in BTreeTest.
Root causes, confirmed by reproducing locally under Valgrind:
- B_TREE_CREATE never initialized currentLoadedPages, so
CHECK_AND_RELEASE_PAGES branched on stack garbage (3 contexts of
"conditional jump depends on uninitialised value")
- B_TREE_PAGE_CREATE malloc'd pages but left rows[], references[] and
padding uninitialized while DISK_WRITE persists the whole struct
(1 context of "syscall write(buf) points to uninitialised bytes");
now uses calloc. The children-clearing loop also wrote one element
past the array (the known BTree.c:276 off-by-one flagged by UBSan)
- BTreeTest never freed the tree: TearDown was commented out
(4 "definitely lost" contexts, up to 2.5 MB in AddMultipleItems);
B_TREE_FREE verified sound under Valgrind before re-enabling it
- Test rows are now zero-initialized since B_TREE_INSERT persists the
full row (value union + padding) to disk
Verified with the real GTest suite built against googletest 1.12.1:
4/4 tests pass and Valgrind reports 0 errors from 0 contexts with the
CI memcheck flags and valgrind.supp.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>1 parent 68e86f4 commit 588ba3f
2 files changed
Lines changed: 12 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
| 133 | + | |
133 | 134 | | |
134 | 135 | | |
135 | 136 | | |
| |||
261 | 262 | | |
262 | 263 | | |
263 | 264 | | |
264 | | - | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
265 | 268 | | |
266 | 269 | | |
267 | 270 | | |
| |||
271 | 274 | | |
272 | 275 | | |
273 | 276 | | |
274 | | - | |
275 | | - | |
| 277 | + | |
276 | 278 | | |
277 | | - | |
278 | 279 | | |
279 | | - | |
280 | 280 | | |
281 | 281 | | |
282 | 282 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
27 | | - | |
| 29 | + | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
| |||
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
38 | | - | |
39 | | - | |
| 40 | + | |
| 41 | + | |
40 | 42 | | |
41 | 43 | | |
42 | 44 | | |
| |||
0 commit comments