From 63efdc7cc81f5135dd2b556b179d4b42da6da783 Mon Sep 17 00:00:00 2001 From: Karl Lehenbauer Date: Thu, 5 Mar 2026 17:08:04 +0000 Subject: [PATCH] fix: always force-exit after analyze to avoid KuzuDB destructor crash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit KuzuDB 0.11.3's native atexit hooks cause a double-free / segfault during natural process shutdown on Node 22+. The existing process.exit(0) workaround was only triggered when embeddings were enabled; without embeddings (the default) the process exited naturally and hit the crash. Always call process.exit(0) after successful completion since KuzuDB is always loaded. Reproducer: `npx gitnexus analyze` on any repo with Node 22 — crashes with "double free or corruption (out)" or "munmap_chunk(): invalid pointer" at the 98% "Saving metadata..." phase. Co-Authored-By: Claude Opus 4.6 --- gitnexus/src/cli/analyze.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/gitnexus/src/cli/analyze.ts b/gitnexus/src/cli/analyze.ts index 7505169bbe..895544a6b3 100644 --- a/gitnexus/src/cli/analyze.ts +++ b/gitnexus/src/cli/analyze.ts @@ -357,10 +357,8 @@ export const analyzeCommand = async ( console.log(''); - // ONNX Runtime registers native atexit hooks that segfault during process - // shutdown on macOS (#38) and some Linux configs (#40). Force-exit to - // bypass them when embeddings were loaded. - if (!embeddingSkipped) { - process.exit(0); - } + // KuzuDB 0.11.3 and ONNX Runtime register native atexit hooks that + // segfault / double-free during process shutdown on Node 22+ (and + // macOS for ONNX — see #38, #40). Force-exit to bypass them. + process.exit(0); };