Skip to content

Segmentation Fault when using list_cosine_similarity in 1.2.2-alpha.19 #220

@pokutuna

Description

@pokutuna

Description

When using the list_cosine_similarity function with @duckdb/node-api version 1.2.2-alpha.19, the application crashes with a segmentation fault.
The same code works correctly with version 1.2.2-alpha.18.

Initially, I thought this might be related to my local build environment or setup, but I've been able to reproduce the issue with minimal code in both my local environment and on a Linux server (Google Cloud Shell). This confirms it's an issue with the library itself rather than environment-specific configuration.

I've only confirmed the issue with list_cosine_similarity, and haven't tested whether other similar functions (like other vector operations) might be affected as well. The scope of the issue beyond this specific function is currently unknown.

Environment

  • Node.js version: v20.12.2, v22.15.1
  • @duckdb/node-api version: 1.2.2-alpha.19
  • Operating systems tested:
    • macOS (darwin-arm64)
    • Linux (via Google Cloud Shell)

Steps to Reproduce

  1. Create a database with a table containing vector embeddings (768-dimension double arrays)
  2. Execute a query using list_cosine_similarity to find the most similar vector to a query vector
  3. The application crashes with a segmentation fault

Error Output

On macOS (darwin-arm64):

[1]    91808 segmentation fault  node index.mjs

Or sometimes:

node:internal/process/promises:289
        triggerUncaughtException(err, true /* fromPromise */);
    ^

[Error: Failed to execute prepared statement]

Node.js v20.12.2

On Linux (x86_64, Node.js v22.15.1, Linux 6.6.87+):

Segmentation fault (core dumped)

Reproduction Repository

I've created a repository to reproduce this issue:
pokutuna/20250521-duckdb-segmentation-fault-repro

The repository contains:

  • A version using alpha.18 (working correctly)
  • A version using alpha.19 (crashing with segmentation fault)
  • Minimal code that isolates the issue to just the list_cosine_similarity functionality
  • Sample data
  • GDB debug logs showing the crash details

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions