mirror of
https://github.com/DeusData/codebase-memory-mcp.git
synced 2026-10-25 06:33:13 +08:00
SIGABRT (free of a non-libmalloc pointer in ts_stack_delete) on the second index_repository in one process, whenever a sequential run is followed by a parallel one. The sequential path parses on the CALLING thread and left its TLS parser alive; the next parallel run switches the global tree-sitter allocator to the slab (cbm_slab_install), the calling thread participates in extraction, reuses the stale parser, and its per-file teardown frees mimalloc-epoch memory through slab_free's foreign-pointer fallback -> plain free() -> libmalloc abort. The v0.9.0 supervisor masks this on the default MCP path (fresh worker process per index); the in-process path and every embedded consumer died. Root-caused with allocator-epoch instrumentation: the victim parser is created at epoch 0 in cbm_pipeline_pass_definitions and deleted at epoch 1 in extract_worker. Two boundary fixes: - run_sequential_pipeline destroys the calling thread's parser at run end (also bounds its memory like the parallel workers already do); - cbm_parallel_extract destroys the calling thread's parser BEFORE cbm_slab_install, so no parser ever crosses the allocator switch. Guards: prod-tier smoke invariant inv_second_index_inprocess (sequential-then-parallel double index over stdio, RED with signal 6 on the unfixed binary — ASan builds mask the allocator seam, so the unit tier cannot catch this class) + suite-tier fork-isolated index_second_inprocess_run_survives_issue773 pinning the in-process double-index contract. Repro 5/5 clean after the fix (was 5/5 abort). Closes #773 Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>