Skip to content

Crash on adding more than 3 rows to DuckDB #25066

@Alexxzz

Description

@Alexxzz

How can we reproduce the crash?

If only:

      await connection.run(
    `
CREATE or REPLACE TABLE ticks (
  datetime TIMESTAMP_MS, 
  open DECIMAL(10, 4),
);
...
    ticks.map((t) => timestampMillisValue(BigInt(t[0]))), // Kline open time
    ticks.map((t) => decimalValue(Number(t[1]), 10, 4)), // Open price
...

Works, but with 3 rows it crashes

import {
  DOUBLE,
  DuckDBDataChunk,
  DuckDBInstance,
  TIMESTAMP_MS,
  timestampMillisValue,
} from '@duckdb/node-api'
import { decimalValue } from '@duckdb/node-api/lib/values'
import { loadTicks } from '../service/BinanceClient'

const runDb = async () => {
  const ticks = await loadTicks({
    symb: 'BTCUSDT',
    interval: '1h',
    limit: 200,
  })

  const instance = await DuckDBInstance.create('my_duckdb.db')

  const connection = await instance.connect()

  await connection.run(
    `
CREATE or REPLACE TABLE ticks (
  datetime TIMESTAMP_MS, 
  open DECIMAL(10, 4),
  high DECIMAL(10, 4),

);
`,
  )
  /*
    low DECIMAL(10, 4),
  close DECIMAL(10, 4),
  volume DECIMAL(10, 4),
   */

  const appender = await connection.createAppender('ticks')

  const chunk = DuckDBDataChunk.create([TIMESTAMP_MS, DOUBLE])
  chunk.setColumns([
    ticks.map((t) => timestampMillisValue(BigInt(t[0]))), // Kline open time
    ticks.map((t) => decimalValue(Number(t[1]), 10, 4)), // Open price
    ticks.map((t) => decimalValue(Number(t[2]), 10, 4)), // High price
    // ticks.map((t) => decimalValue(Number(t[3]), 10, 4)), // Low price
    // ticks.map((t) => decimalValue(Number(t[4]), 10, 4)), // Close price
    // ticks.map((t) => decimalValue(Number(t[5]), 10, 4)), // Volume
  ])
  appender.appendDataChunk(chunk)
  appender.flushSync()
}

runDb()

Relevant log output

Stack Trace (bun.report)

Bun v1.3.2 (b131639) on macos aarch64 [RunCommand]

Segmentation fault at address 0x00000000

  • 7 unknown/js code
  • NapiClass.cpp:68: long long Zig::NapiClass_ConstructorFunction<false>
  • 1 unknown/js code
  • jsc_llint_commonCallOp__llintOpWithMetadata__llintOpWithReturn__llintOp__commonOp__fn__fn__makeReturn__fn__fn__fn__666_callHelper__dispatch_LowLevelInterpreter64_asm_2527
  • llint_call_javascript
  • Interpreter.cpp:1385: JSC::Interpreter::executeCall
  • GetterSetter.cpp:60: JSC::GetterSetter::callGetter
  • PropertySlot.h:412: JSC::LLInt::performLLIntGetByID
  • LLIntSlowPaths.cpp:974: llint_slow_path_get_by_id
  • jsc_llint_llintOpWithMetadata__llintOpWithReturn__llintOp__commonOp__fn__fn__makeReturn__fn__fn__fn__opGetByIdSlow_LowLevelInterpreter_asm_655
  • jsc_llint_commonCallOp__llintOpWithMetadata__llintOpWithReturn__llintOp__commonOp__fn__fn__makeReturn__fn__fn__fn__666_callHelper__dispatch_LowLevelInterpreter64_asm_2527
  • jsc_llint_commonCallOp__llintOpWithMetadata__llintOpWithReturn__llintOp__commonOp__fn__fn__makeReturn__fn__fn__fn__666_callHelper__dispatch_LowLevelInterpreter64_asm_2527
  • jsc_llint_commonCallOp__llintOpWithMetadata__llintOpWithReturn__llintOp__commonOp__fn__fn__makeReturn__fn__fn__fn__666_callHelper__dispatch_LowLevelInterpreter64_asm_2527
  • jsc_llint_commonCallOp__llintOpWithMetadata__llintOpWithReturn__llintOp__commonOp__fn__fn__makeReturn__fn__fn__fn__684_callHelper__dispatch_LowLevelInterpreter64_asm_2527

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

Sentry Issue: BUN-110Y

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions