atuinsh/atuin · critical
exceeded maximum length
Error message
exceeded maximum length
What it means
`Location::of` maps a flat u32 index to bucket/entry coordinates, first doing `index.checked_add(SKIP).expect("exceeded maximum length")` with SKIP=32. The top 32 index values (index > 4,294,967,263) have no representable location, so the panic marks the last few slots of the index space as reserved - effectively the same 2^32 capacity ceiling enforced by the push/extend guards.
Source
Thrown at crates/atuin-nucleo/src/boxcar.rs:613
#[derive(Debug)]
struct Location {
// the index of the bucket
bucket: u32,
// the length of `bucket`
bucket_len: u32,
// the index of the entry in `bucket`
entry: u32,
}
// skip the shorter buckets to avoid unnecessary allocations.
// this also reduces the maximum capacity of a vector.
const SKIP: u32 = 32;
const SKIP_BUCKET: u32 = (u32::BITS - SKIP.leading_zeros()) - 1;
impl Location {
fn of(index: u32) -> Location {
let skipped = index.checked_add(SKIP).expect("exceeded maximum length");
let bucket = u32::BITS - skipped.leading_zeros();
let bucket = bucket - (SKIP_BUCKET + 1);
let bucket_len = Location::bucket_len(bucket);
let entry = skipped ^ bucket_len;
Location {
bucket,
bucket_len,
entry,
}
}
fn bucket_len(bucket: u32) -> u32 {
1 << (bucket + SKIP_BUCKET)
}
/// The entry index at which the next bucket should be pre-allocated.
fn alloc_next_bucket_entry(&self) -> u32 {View on GitHub (pinned to 15fe1318f1)
Solutions
- Enforce the same bound the public paths need: total items <= 4,294,967,263 (u32::MAX minus SKIP)
- Shard datasets rather than filling one vector to its ceiling
- Treat a hit through a public API as an upstream capacity bug and report it
Example fix
// before
vec.push(value, fill); // may reach the reserved tail indices
// after
const MAX_INDEX: u64 = u32::MAX as u64 - 32;
if inflight_count < MAX_INDEX {
vec.push(value, fill);
inflight_count += 1;
} else {
return Err(CapacityError);
} Defensive patterns
Strategy: validation
Validate before calling
// Enforce the reserved top-of-index-space margin (SKIP = 32)
const MAX_ITEMS: u64 = u64::from(u32::MAX - 32);
if inflight_count >= MAX_ITEMS {
return Err(CapacityError);
} Prevention
- Apply the same u32::MAX-minus-32 bound your pushes already need
- Do not call boxcar's Location/index internals directly with unvalidated indices
- Shard rather than fill one vector to its ceiling
When it happens
Trigger: Reserving the final indices after ~4.29 billion pushes (the counter guards in push/extend usually fire first); calling boxcar internals directly with a near-u32::MAX index.
Common situations: Not reachable via atuin/nucleo public APIs under realistic data sizes; only fuzzing or synthetic multi-billion-row workloads.
Related errors
- overflowed maximum capacity
- exceeded maximum allocation size
- creating threadpool failed
- payload length fits in u32
- issue in stats average query
AI-assisted analysis of atuinsh/atuin@15fe1318f1 (2026-08-19).
Data as JSON: /api/errors/30afefacd3d4678a.
Report an issue: GitHub.