#4315·lancedb

bug(python): Writer panics with debug_assert!("tail_bit_savings must be non-zero") in bitpacking when a dictionary-encoded int64 column contains negative values

Author: zhuang-kejuCreated Sep 24, 2026Updated Sep 24, 2026
Labelsbug

LanceDB version

0.40.0b7

What happened?

create_table panics in debug builds on an int64 column whose dictionary contains negatives: tail_bit_savings must be non-zero

the bit-width stat ORs raw values without min/max centering (negatives → full 64-bit width), the bitpacking selector lacks the estimator's full-width guard so it picks a zero-savings compressor. However, the runt-tail chunk then asserts tail_bit_savings > 0. Release builds are unaffected (raw-tail fallback, correct data).

Expected: the create table call should be successful. The negative integers could also be compressed with min-max centering.

Are there known steps to reproduce?

run the below python trigger to reproduce it.

python
import os
import random
import shutil
import sys

os.environ.setdefault("RUST_BACKTRACE", "1")

import lancedb
import pyarrow as pa

DB_DIR = sys.argv[1] if len(sys.argv) > 1 else "/tmp/lancedb_tailbit_repro"
TABLE = "t"

shutil.rmtree(DB_DIR, ignore_errors=True)
db = lancedb.connect(DB_DIR)

schema = pa.schema([
    pa.field("f0", pa.int64(), nullable=True),
])

rng = random.Random(42)
VALUES = list(range(-800, 800))          # 1600 distinct, negatives included
rows = [{"f0": VALUES[rng.randrange(len(VALUES))]} for _ in range(9216)]

print("[setup] creating table: 9216 rows, int64 column, 1600 distinct values (1600 % 1024 = 576)") # the assert is at the 576 block.
table = db.create_table(TABLE, data=rows, schema=schema)
print(f"[ok] no panic, wrote {table.count_rows()} rows")