Repository navigation
Commit e45d705
fix(mcp): free the extraction bitset cache on the in-process auto-index thread (LSan)
cbm_kind_in_set lazily builds a THREAD-LOCAL node-type bitset cache during
extraction. That cache must be freed before a worker thread exits, or the
calloc'd bitsets are orphaned when the thread's TLS is torn down and
LeakSanitizer reports them at process exit. Parallel workers already free it
(pass_parallel.c:993) and the main thread frees it at process teardown; the
IN-PROCESS sequential auto-index runs extraction on autoindex_thread — a
short-lived pthread joined by cbm_mcp_server_free — and was the one gap: it
built the cache but never freed it (360 bytes in 9 allocations leaked, all from
ks_build).
This is a PRE-EXISTING latent leak: the extraction path and autoindex_thread are
byte-identical to main. It is newly EXPOSED by DeusData#713's new
autoindex_limit_admits_non_git_root_under_limit test, the first LSan-observed
path that runs an in-process auto-index and joins the worker thread in-process —
so the fix ships with the test that exposes it.
Free the calling thread's bitset cache after cbm_pipeline_free(p), mirroring the
established per-worker-thread teardown. Zero behavior change to the CLI/main
path. macOS LSan lane, mcp suite: 360 B / 9 allocations -> 0.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>1 parent 7e73b48 commit e45d705
1 file changed
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17383 | 17383 | | |
17384 | 17384 | | |
17385 | 17385 | | |
| 17386 | + | |
| 17387 | + | |
| 17388 | + | |
| 17389 | + | |
| 17390 | + | |
| 17391 | + | |
| 17392 | + | |
| 17393 | + | |
| 17394 | + | |
| 17395 | + | |
17386 | 17396 | | |
17387 | 17397 | | |
17388 | 17398 | | |
| |||
17422 | 17432 | | |
17423 | 17433 | | |
17424 | 17434 | | |
| 17435 | + | |
17425 | 17436 | | |
17426 | 17437 | | |
17427 | 17438 | | |
| |||
0 commit comments