Skip to content

Bug: COPY FROM <pandas DataFrame> segfaults / aborts with heap corruption when a nullable STRING column has >2113 nulls in one call #672

Description

@gepr

Ladybug version

v0.18.0

What operating system are you using?

Pop!_OS 22.04 LTS \n \l

What happened?

This Issue was authored by Claude Code using Sonnet 5.

Description

COPY <table> FROM <df> crashes with heap corruption (nondeterministic SIGSEGV or SIGABRT) when the DataFrame has an all-null (or heavily-null) STRING column and the row count exceeds 2113 rows committed in a single COPY ca
ll.

Inherited from Kuzu 0.11.3 — Ladybug is a fork of that codebase and still has the bug. Kuzu itself is abandoned upstream, so Ladybug is the version worth fixing.

Environment

  • ladybug 0.18.0
  • pandas 2.2.3
  • pyarrow 19.0.0
  • numpy 2.2.6
  • Python 3.13 (Linux)

Are there known steps to reproduce?

Reproduction

See attached script: ladybug_copy_null_segfault_repro.py

Observed Behavior

The exact threshold and failure mode are stable and were confirmed across multiple runs:

N Result
2050, 2100, 2113 succeeds, exact row count returned
2114 crashes
2200, 2500 crashes

Failure modes at N > 2113 are nondeterministic across runs but all indicate heap corruption inside the native COPY-from-DataFrame path:

  • Segmentation fault (core dumped)
  • free(): invalid next size (normal) (SIGABRT)
  • munmap_chunk(): invalid pointer (SIGABRT)

Expected behavior

COPY FROM <df> should succeed regardless of null count in a STRING column, the same as the file-based path does.

Workaround

Writing the DataFrame to a parquet file and using COPY <table> FROM '<file>.parquet' instead of COPY <table> FROM <df> avoids the bug — verified up to 10k rows (also independently re-verified at 5k rows with an all-null STRING colum
n) with the in-memory DataFrame path.

Notes on related issues

I searched existing issues and didn't find an exact duplicate, but two are adjacent and may share root cause in the native STRING handling for the DataFrame ingestion path:

Given the coincidence of STRING-column corruption reports on the same DataFrame-ingestion path, it may be worth checking whether #647 and this issue share a root cause in the string-chunk/dictionary encoding used when materializing pand
as STRING columns, even though the symptoms differ (crash vs. silent corruption).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions