From f61f61d94ccb5cc782b770256a64fd7ffbd9c53b Mon Sep 17 00:00:00 2001 From: Hector Prats Date: Fri, 8 May 2026 18:16:01 +0200 Subject: [PATCH] fix(windows): skip FTS extension load in pool-adapter on Windows to prevent SIGSEGV MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit LOAD EXTENSION fts crashes the process with SIGSEGV on Windows when the FTS extension binary is not installed locally. This is an @ladybugdb/core native bug — the extension loader hits an unhandled error path that raises a native signal instead of a JS exception, so try/catch cannot protect here. Add a process.platform === 'win32' guard in both doInitLbug and initLbugWithDb. When skipped, bm25-index.js catches the resulting Kuzu catalog errors (CREATE_FTS_INDEX not defined) and returns empty BM25 results gracefully. All graph queries (cypher, context, impact) are unaffected. This is patch 9 of the Windows fix series for gitnexus on Windows: patch 8 (same PR) already fixed INSTALL VECTOR SIGSEGV in lbug-adapter.ts. pool-adapter.ts is the separate MCP-server code path that was not covered. --- gitnexus/src/core/lbug/pool-adapter.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/gitnexus/src/core/lbug/pool-adapter.ts b/gitnexus/src/core/lbug/pool-adapter.ts index ed999907e..f18d7fcc3 100644 --- a/gitnexus/src/core/lbug/pool-adapter.ts +++ b/gitnexus/src/core/lbug/pool-adapter.ts @@ -420,7 +420,17 @@ async function doInitLbug(repoId: string, dbPath: string): Promise { // install; analyze owns extension installation. If LOAD fails, search // features degrade gracefully and the user-facing query path proceeds. if (!shared.ftsLoaded) { - shared.ftsLoaded = await loadFTSExtension(available[0], { policy: 'load-only' }); + // Windows guard: LOAD EXTENSION fts crashes with SIGSEGV on Windows when + // the FTS extension binary is not installed locally (@ladybugdb/core native + // bug — the extension loader hits an unhandled error path that signals SIGSEGV + // rather than throwing a JS exception, so try/catch cannot protect here). + // Skip the load on Windows; bm25-index.js catches the resulting Kuzu catalog + // errors and returns empty BM25 results gracefully. Graph queries are unaffected. + if (process.platform === 'win32') { + shared.ftsLoaded = true; + } else { + shared.ftsLoaded = await loadFTSExtension(available[0], { policy: 'load-only' }); + } } // Register pool entry only after all connections are pre-warmed and FTS is @@ -484,8 +494,13 @@ export async function initLbugWithDb( // Load FTS extension if not already loaded on this Database. // policy: 'load-only' — same contract as initLbug above; the read pool // must not block on a network install during query execution. + // Windows guard: same SIGSEGV risk as doInitLbug above — skip on Windows. if (!shared.ftsLoaded) { - shared.ftsLoaded = await loadFTSExtension(available[0], { policy: 'load-only' }); + if (process.platform === 'win32') { + shared.ftsLoaded = true; + } else { + shared.ftsLoaded = await loadFTSExtension(available[0], { policy: 'load-only' }); + } } pool.set(repoId, {