Skip to content

fix: overflow for large bit counts and large document counts in b… - #99

Merged
rebasedming merged 1 commit into
mainfrom
fix/overflow
Jan 30, 2026
Merged

fix: overflow for large bit counts and large document counts in b…#99
rebasedming merged 1 commit into
mainfrom
fix/overflow

Conversation

@rebasedming

Copy link
Copy Markdown
Collaborator

…itpacker (#97)

What

Fixes a panic in FileSlice::combine_ranges that occurs when querying segments with high document counts (e.g., >67M docs with 64-bit values). It was introduced in #56.

The issue was caused by u32 integer overflow during doc_id * num_bits calculations. This resulted in wrapped-around offsets and invalid ranges where start > end, triggering an assertion failure in the file slicing logic.

How

Cast from u32 to usize before multiplication in a variety of locations.

Additionally, add an assert in block_oblivious_range to provide a clear failure if an out-of-bounds start is requested, preventing invalid ranges from reaching FileSlice.

Tests

Adds a test that fails with overflow before the fix.

…itpacker (#97)

## What

Fixes a panic in `FileSlice::combine_ranges` that occurs when querying segments with high document counts (e.g., >67M docs with 64-bit values). It was introduced in #56.

The issue was caused by `u32` integer overflow during `doc_id * num_bits` calculations. This resulted in wrapped-around offsets and invalid ranges where `start > end`, triggering an assertion failure in the file slicing logic.

## How

Cast from `u32` to `usize` before multiplication in a variety of locations.

Additionally, add an assert in `block_oblivious_range` to provide a clear failure if an out-of-bounds start is requested, preventing invalid ranges from reaching `FileSlice`.

## Tests

Adds a test that fails with overflow before the fix.
@rebasedming
rebasedming merged commit aa5a0e1 into main Jan 30, 2026
6 checks passed
@rebasedming
rebasedming deleted the fix/overflow branch January 30, 2026 21:04
rebasedming added a commit that referenced this pull request Feb 10, 2026
rebasedming added a commit that referenced this pull request Feb 10, 2026
rebasedming added a commit that referenced this pull request Jun 22, 2026
Co-authored-by: Stu Hood <stuhood@paradedb.com>
(cherry picked from commit 35502b2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants