Skip to content

fix: bitmap iterator exhaustion in mask_to_offset_ranges#6046

Merged
Xuanwo merged 5 commits intolance-format:mainfrom
wkalt:fix/mask-offset-ranges-panic
Mar 9, 2026
Merged

fix: bitmap iterator exhaustion in mask_to_offset_ranges#6046
Xuanwo merged 5 commits intolance-format:mainfrom
wkalt:fix/mask-offset-ranges-panic

Conversation

@wkalt
Copy link
Copy Markdown
Contributor

@wkalt wkalt commented Feb 27, 2026

In mask_to_offset_ranges, the RangeWithBitmap case advanced the bitmap iterator using a global offset (addr - range.start + offset_start) instead of a range-local position (addr - range.start). When a RangeWithBitmap segment appeared after other segments (offset_start > 0), the iterator was advanced past its end, causing a panic.

The fix separates range-local iteration from the final offset calculation: iterate the bitmap using position_in_range, then add offset_start at the end.

Includes an integration test that reproduces the panic through the user-facing API: write 2 fragments with stable row IDs, delete some rows, compact, create a BTree index, then run a filtered scan.

…egment sequences

In mask_to_offset_ranges, the RangeWithBitmap case advanced the bitmap
iterator using a global offset (addr - range.start + offset_start)
instead of a range-local position (addr - range.start). When a
RangeWithBitmap segment appeared after other segments (offset_start > 0),
the iterator was advanced past its end, causing a panic.

The fix separates range-local iteration from the final offset
calculation: iterate the bitmap using position_in_range, then add
offset_start at the end.

Includes an integration test that reproduces the panic through the
user-facing API: write 2 fragments with stable row IDs, delete some
rows, compact, create a BTree index, then run a filtered scan.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions github-actions Bot added the bug Something isn't working label Feb 27, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Review

Clean, correct fix. No P0/P1 issues.

The bitmap in RangeWithBitmap is indexed by position within the range (0 to range.len()-1), so using addr - range.start + offset_start to advance the iterator was wrong whenever offset_start > 0 — it would seek past the bitmap's end and panic on .unwrap(). The fix properly separates range-local iteration (position_in_range) from the global offset calculation (offset_start + position_in_range - holes_passed), consistent with how RangeWithHoles handles the analogous logic.

Test coverage is good — the integration test reproduces the exact multi-segment scenario through the public API.

LGTM.

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Collaborator

@Xuanwo Xuanwo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for working on this!

@Xuanwo Xuanwo merged commit 860039a into lance-format:main Mar 9, 2026
38 of 39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants