Description
The WASM engine intermittently crashes with a V8 fatal error or segfault (exit code 139) after the build successfully completes. The graph data is written correctly, but the process crashes during cleanup/shutdown.
Reproduction
# Install dev build 3.9.4-dev.8
# Run WASM full build on codegraph's own src/ (~309 TS files)
codegraph build src --engine wasm --no-incremental
Crash rate: 2 out of 5 runs (40%) on Windows 11, Node 22.18.0.
Crash signatures
V8 Fatal Error:
Fatal error in , line 0
# unreachable code
Segfault:
Exit code 139 (Segmentation fault)
Stack trace points to tree-sitter WASM:
function get type() {
return this.tree.language.types[this.typeId] || "ERROR";
}
The crash occurs during walkWithVisitors → walk recursion in the complexity/CFG/dataflow analysis phase, or during process shutdown GC cleanup of WASM objects.
Environment
- Version: 3.9.4-dev.8
- OS: Windows 11 Pro 10.0.26200
- Node: v22.18.0
- Engine: WASM only (native engine unaffected)
Impact
- Build data is written correctly before the crash — the graph DB is valid
- Exit code is non-zero, which would break CI pipelines that check exit status
- The crash is non-deterministic, making it hard to debug
Possible causes
- Tree-sitter WASM parser objects not being properly disposed before Node GC runs
- Race condition between WASM memory cleanup and V8 garbage collector
- Deep recursion in
walkWithVisitors exhausting WASM stack space on larger codebases
Description
The WASM engine intermittently crashes with a V8 fatal error or segfault (exit code 139) after the build successfully completes. The graph data is written correctly, but the process crashes during cleanup/shutdown.
Reproduction
Crash rate: 2 out of 5 runs (40%) on Windows 11, Node 22.18.0.
Crash signatures
V8 Fatal Error:
Segfault:
Stack trace points to tree-sitter WASM:
The crash occurs during
walkWithVisitors→walkrecursion in the complexity/CFG/dataflow analysis phase, or during process shutdown GC cleanup of WASM objects.Environment
Impact
Possible causes
walkWithVisitorsexhausting WASM stack space on larger codebases