Skip to content

WASM engine: intermittent V8 crash / segfault after build completes #931

@carlos-alm

Description

@carlos-alm

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 walkWithVisitorswalk 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions