-
Notifications
You must be signed in to change notification settings - Fork 77
Description
Environment
- OS: Windows 11 Pro
- Version: 0.4.10
- Go runtime: 1.26.1 (from stack trace)
Description
index_repository with mode=full crashes with a Windows stack overflow exception (0xc00000fd = STATUS_STACK_OVERFLOW) when the project contains a large .sql file (~4.5 MB). The crash occurs in the CGo tree-sitter parser (cbm_extract_file) during pass2.definitions.
This also means the MCP server always crashes on startup, since the server triggers a mode=full pipeline automatically after the notifications/initialized handshake. Claude Code marks the server as "failed" every session, making the MCP completely unusable without a workaround.
Steps to Reproduce
- Have a project containing a
.sqlfile ≥ ~4 MB (e.g. a database dump with large INSERT statements) - Run:
codebase-memory-mcp cli index_repository '{"repo_path": "/path/to/project", "mode": "full"}' - Observe segfault / exit code 139
Confirmed reproducible — removing the file from indexing via .cbmignore makes the crash disappear immediately.
Stack Trace
Exception 0xc00000fd 0x1 0xcd87803f18 0x7ff7c2ff7f5d
PC=0x7ff7c2ff7f5d
signal arrived during external code execution
runtime.cgocall(0x7ff7c2feb1e0, 0x2dd73843fbc8)
C:/hostedtoolcache/windows/go/1.26.1/x64/src/runtime/cgocall.go:167 +0x3e
github.com/DeusData/codebase-memory-mcp/internal/cbm._Cfunc_cbm_extract_file(0x2dd738882000, 0x4533a3, 0x21, ...)
_cgo_gotypes.go:467 +0x51
github.com/DeusData/codebase-memory-mcp/internal/cbm.ExtractFile(...)
cbm.go:254 +0x18b
github.com/DeusData/codebase-memory-mcp/internal/pipeline.cbmParseFileFromSource(...)
pipeline_cbm.go:46 +0x1bc
github.com/DeusData/codebase-memory-mcp/internal/pipeline.cbmParseFile(...)
pipeline_cbm.go:30 +0x109
github.com/DeusData/codebase-memory-mcp/internal/pipeline.(*Pipeline).passDefinitions.func1()
pipeline.go:1093 +0x10b
Root Cause (hypothesis)
The tree-sitter SQL grammar recurses deeply on large files (bulk INSERT dumps, etc.), exhausting the C stack. Windows has a smaller default thread stack than Linux/macOS, making this Windows-specific. mode=fast is unaffected because it skips large files.
Workaround
Add a .cbmignore file in the repo root to exclude large SQL files:
path/to/large-dump.sql
Expected Behavior
The parser should either:
- Detect and skip files above a configurable size threshold before passing to tree-sitter
- Increase the C stack size for the parser goroutine (
runtime/debug.SetMaxStackor spawning a thread with a larger stack) - Gracefully recover from C-level stack overflows instead of crashing the whole process