GitoxideLabs/gitoxide · error
in-bound distance of deltas
Error message
in-bound distance of deltas
What it means
`Entry::base_pack_offset(distance)` computes the delta base's pack offset by subtracting `distance` from the entry offset. The method is documented to panic if the distance causes an underflow or is invalid; the error means the caller supplied a delta base distance that reaches before the start of the pack, indicating corrupt delta data.
Solutions
- Validate `distance <= entry.pack_offset()` before calling, or use `checked_base_pack_offset(distance)` which returns Option
- Re-verify / re-download the pack if corruption is suspected (`git fsck`)
- Switch to `checked_base_pack_offset` and handle None explicitly
Example fix
// before
let base = entry.base_pack_offset(distance); // panics on bad distance
// after
let base = entry.checked_base_pack_offset(distance)
.ok_or_else(|| anyhow::anyhow!("invalid delta base distance {distance}"))?; Defensive patterns
Strategy: validation
Validate before calling
if distance > entry.pack_offset() { return Err(anyhow!("delta base distance {} exceeds entry offset", distance)); } Try / catch
// prefer the checked API over the panicking one
let base = entry.checked_base_pack_offset(distance)
.ok_or_else(|| anyhow!("invalid delta base distance"))?; Prevention
- Always use `checked_base_pack_offset` in library-style code
- Validate delta headers from untrusted packs before offset math
- Run pack verification on downloaded packs before delta resolution
When it happens
Trigger: Calling `base_pack_offset(distance)` on an OFS_DELTA/REF_DELTA entry with a distance larger than the entry's own pack offset, e.g. from a corrupted pack or a wrongly parsed header.
Common situations: Traversing corrupted packs, manually constructed delta entries, or code that mis-computes base distances when reimplementing pack parsing.
Related errors
- BUG: pack now is smaller than all previously seen entries
- if you see this the object database is correct as a delta…
- Cannot use iter_v1() on index of type
- Cannot use iter_v2() on index of type
- must have been resolved
AI-assisted analysis of GitoxideLabs/gitoxide@e73179060b (2026-09-08).
Data as JSON: /api/errors/5d825afee486afb4.
Report an issue: GitHub.
Appendix: source
Thrown at gix-pack/src/data/entry/mod.rs:46
}
}
/// Access
impl Entry {
/// Compute the pack offset to the base entry of the object represented by this entry, or
/// return `None` if the distance would underflow or is invalid.
pub fn checked_base_pack_offset(&self, distance: u64) -> Option<data::Offset> {
Header::verified_base_pack_offset(self.pack_offset(), distance)
}
/// Compute the pack offset to the base entry of the object represented by this entry.
///
/// # Panics
///
/// Panics if the `distance` will cause an underflow or is invalid.
pub fn base_pack_offset(&self, distance: u64) -> data::Offset {
self.checked_base_pack_offset(distance)
.expect("in-bound distance of deltas")
}
/// The pack offset at which this entry starts
pub fn pack_offset(&self) -> data::Offset {
self.data_offset - self.header_size() as u64
}
/// The amount of bytes used to describe this entry in the pack.
///
/// For entries decoded from pack data this returns the actual encoded header length, including
/// non-canonical overlong size encodings accepted by Git. This is the length to use for offset
/// reconstruction because the header starts at [`Self::pack_offset()`] and the compressed data
/// starts at [`Entry::data_offset`].
///
/// If [`Entry::encoded_header_size`] is `0`, the actual encoded length is unknown and this falls
/// back to [`Header::size()`], which computes the canonical serialized length from the decoded
/// header and decompressed size.
pub fn header_size(&self) -> usize {
if self.encoded_header_size == 0 {
self.header.size(self.decompressed_size)View on GitHub (pinned to e73179060b)