Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bun crashes opening DuckDB #17216

Open
fleitz opened this issue Feb 9, 2025 · 2 comments
Open

Bun crashes opening DuckDB #17216

fleitz opened this issue Feb 9, 2025 · 2 comments
Assignees
Labels
crash An issue that could cause a crash linux An issue that occurs on Linux

Comments

@fleitz
Copy link

fleitz commented Feb 9, 2025

How can we reproduce the crash?

Increase the number of microtasks until it crashes. Usually works fine below 5, definitely crashes at 100 or more.

import { DuckDBInstance } from '@duckdb/node-api'
import { randomUUIDv7 } from "bun";

const run = async () => {
    for (let i = 0; i < 10000; i++) {
        const id = randomUUIDv7();
        const path = `./${id}.db`
        const db = await DuckDBInstance.create(path)
        const connection = await db.connect()
        await connection.close()
    }
}

for(let i = 0; i < 10; i++) {
    queueMicrotask(() => {
        run()
    })
}
gdb --args bun run index.ts
__memmove_evex_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:872
872     ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S: No such file or directory.
(gdb) backtrace
#0  __memmove_evex_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:872
#1  0x00007fff9c39b8d0 in std::string::_Rep::_M_clone(std::allocator<char> const&, unsigned long) () from /lib/x86_64-linux-gnu/libstdc++.so.6
#2  0x00007fff9c39c344 in std::string::assign(std::string const&) () from /lib/x86_64-linux-gnu/libstdc++.so.6
#3  0x00007fff9dc73d12 in duckdb::DatabaseInstance::Configure(duckdb::DBConfig&, char const*) ()
   from /home/fred/src/duckdb_crash/node_modules/@duckdb/node-bindings-linux-x64/libduckdb.so
#4  0x00007fff9dc7dbef in duckdb::DatabaseInstance::Initialize(char const*, duckdb::DBConfig*) ()
   from /home/fred/src/duckdb_crash/node_modules/@duckdb/node-bindings-linux-x64/libduckdb.so
#5  0x00007fff9dc7e707 in duckdb::DuckDB::DuckDB(char const*, duckdb::DBConfig*) ()
   from /home/fred/src/duckdb_crash/node_modules/@duckdb/node-bindings-linux-x64/libduckdb.so
#6  0x00007fff9dbaafc6 in duckdb_open_internal(duckdb::DBInstanceCacheWrapper*, char const*, _duckdb_database**, _duckdb_config*, char**) ()
   from /home/fred/src/duckdb_crash/node_modules/@duckdb/node-bindings-linux-x64/libduckdb.so
#7  0x00007fffa802a741 in OpenWorker::Execute() () from /home/fred/src/duckdb_crash/node_modules/@duckdb/node-bindings-linux-x64/duckdb.node
#8  0x00007fffa802a8c5 in Napi::AsyncWorker::OnAsyncWorkExecute(napi_env__*, void*) ()
   from /home/fred/src/duckdb_crash/node_modules/@duckdb/node-bindings-linux-x64/duckdb.node
#9  0x000000000308aff9 in ?? ()
#10 0x0000000000000000 in ?? ()

Relevant log output

Stack Trace (bun.report)

Bun v1.2.2 (c1708ea) on linux x86_64 [RunCommand]

Segmentation fault at address 0x081DA570

Features: tsconfig_paths, process_dlopen, Bun.stderr, Bun.stdout, fetch, http_server, jsc, transpiler_cache, tsconfig, tsconfig

Sentry Issue: BUN-7G

@fleitz fleitz added the crash An issue that could cause a crash label Feb 9, 2025
@github-actions github-actions bot added the linux An issue that occurs on Linux label Feb 9, 2025
@jraymakers
Copy link

I don't know why the crash is occurring, but the code above is an anti-pattern. It's recommended to create a single DuckDB instance per process, and use the ATTACH command to load (possibly multiple) databases into that instance. Creating thousands of DuckDB instances, especially at such a high rate, is not advised.

@RiskyMH
Copy link
Member

RiskyMH commented Feb 10, 2025

Probably the same issue of #13910

Also if it works in Node but not Bun, please only open issues here :)

@190n 190n self-assigned this Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash An issue that could cause a crash linux An issue that occurs on Linux
Projects
None yet
Development

No branches or pull requests

4 participants