Skip to content

[WIP] index header bucket reader async readahead scratch r409 - #16498

Open
francoposa wants to merge 9 commits into
r409from
francoposa/index-header-bucket-reader-async-readahead-scratch-r409
Open

[WIP] index header bucket reader async readahead scratch r409#16498
francoposa wants to merge 9 commits into
r409from
francoposa/index-header-bucket-reader-async-readahead-scratch-r409

Conversation

@francoposa

Copy link
Copy Markdown
Contributor

What this PR does

Which issue(s) this PR fixes or relates to

Fixes #

Checklist

  • Tests updated.
  • Documentation added.
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]. If changelog entry is not needed, please add the changelog-not-needed label to the PR.
  • about-versioning.md updated with experimental features.

@francoposa
francoposa requested a review from a team as a code owner August 30, 2026 03:16
@francoposa francoposa added the changelog-not-needed PRs that don't need a CHANGELOG.md entry label Aug 30, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ca47b41. Configure here.

readN, err := io.ReadFull(headPromise, bbar.peekBuf[peekBytesWritten:peekBytesWritten+toRead])
peekBytesWritten += readN
if err != nil {
return nil, err

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Failed Peek corrupts buffered state

High Severity

Peek grows peekBuf to the requested length before the fill completes. On a promise error it returns without shrinking peekBuf back to the bytes actually copied. The next Peek, Read, or Skip treats those unfilled bytes as valid data, so a retry can succeed with zeros or stale tail bytes and shift the stream.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit ca47b41. Configure here.

bbar.readOffset += bytesSkipped

// Slide any unconsumed bytes from peekBuf to the beginning of the slice and truncate.
n := copy(bbar.peekBuf, bbar.peekBuf[bytesSkipped:])

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Negative Skip and Peek panic

High Severity

Skip and Peek only reject counts larger than Len(), so a negative count passes the check. Skip then slices peekBuf at a negative index and panics; Peek clamps n to a negative value via min and panics on peekBuf[:n]. Decbuf.SkipUvarintBytes can pass a negative int when a corrupt varint overflows, so a bad index header can crash the process.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit ca47b41. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-not-needed PRs that don't need a CHANGELOG.md entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant