{"record":{"id":"f8a9b4a628eebca4","repo":"atuinsh/atuin","slug":"overflowed-maximum-capacity","errorCode":null,"errorMessage":"overflowed maximum capacity","messagePattern":"overflowed maximum capacity","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/atuin-nucleo/src/boxcar.rs","lineNumber":139,"sourceCode":"\n            // bucket is uninitialized\n            if entries.is_null() {\n                return None;\n            }\n\n            // safety: `location.entry` is always in bounds for it's bucket\n            let entry = Bucket::<T>::get(entries, location.entry, self.columns);\n\n            // safety: the entry is active\n            (*entry).active.load(Ordering::Acquire).then(|| Entry::read(entry, self.columns))\n        }\n    }\n\n    /// Appends an element to the back of the vector.\n    pub fn push(&self, value: T, fill_columns: impl FnOnce(&T, &mut [Utf32String])) -> u32 {\n        let index = self.inflight.fetch_add(1, Ordering::Release);\n        // the inflight counter is a `u64` to catch overflows of the vector'scapacity\n        let index: u32 = index.try_into().expect(\"overflowed maximum capacity\");\n        let location = Location::of(index);\n\n        // eagerly allocate the next bucket if we are close to the end of this one\n        if index == (location.bucket_len - (location.bucket_len >> 3)) {\n            if let Some(next_bucket) = self.buckets.get(location.bucket as usize + 1) {\n                Vec::get_or_alloc(next_bucket, location.bucket_len << 1, self.columns);\n            }\n        }\n\n        // safety: `location.bucket` is always in bounds\n        let bucket = unsafe { self.buckets.get_unchecked(location.bucket as usize) };\n        let mut entries = bucket.entries.load(Ordering::Acquire);\n\n        // the bucket has not been allocated yet\n        if entries.is_null() {\n            entries = Vec::get_or_alloc(bucket, location.bucket_len, self.columns);\n        }\n","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/atuinsh/atuin/blob/15fe1318f1df51de604262eb50734c9883d48e7b/crates/atuin-nucleo/src/boxcar.rs#L121-L157","documentation":"`boxcar::Vec::push` reserves a slot by incrementing an `inflight` u64 counter and converting it to u32 with `.expect(\"overflowed maximum capacity\")`. The conversion fails once 2^32 items are already in flight: the lock-free vector's u32 index space is full. This is a hard capacity ceiling - atuin-nucleo cannot index more than 4,294,967,295 items.","triggerScenarios":"Calling `push` (e.g. injecting into a `Nucleo` matcher) after roughly 4.29 billion prior pushes/extends on the same instance, such as a loop that re-injects the whole dataset per keystroke without resetting.","commonSituations":"Unreachable for atuin's real history workloads; appears in stress tests, fuzzing, or bugs that re-push the entire dataset repeatedly.","solutions":["Bound the number of pushed items to `u32::MAX` by tracking a running count and stopping before the ceiling","Ensure the dataset is pushed exactly once - no re-injection loops that duplicate entries","If you genuinely need more rows, shard across multiple matcher instances"],"exampleFix":"// before\nmatcher.push(item, |item, cols| fill(item, cols));\n\n// after\nconst CEILING: u64 = u32::MAX as u64;\nif pushed < CEILING {\n    matcher.push(item, |item, cols| fill(item, cols));\n    pushed += 1;\n} else {\n    // report capacity exhaustion instead of panicking\n}","handlingStrategy":"validation","validationCode":"// Bound total pushes to the u32 index space\nconst CEILING: u64 = u32::MAX as u64;\nif injected_count >= CEILING {\n    return Err(CapacityError);\n}\nmatcher.push(item, fill);\ninjected_count += 1;","typeGuard":"fn fits_u32_index(count: u64) -> bool {\n    count < u64::from(u32::MAX)\n}","tryCatchPattern":null,"preventionTips":["Track a cumulative injected-item counter instead of relying on the library's internal overflow panic","Push each dataset entry once; never re-inject inside per-keystroke loops","Shard datasets larger than ~4B rows across multiple matcher instances"],"tags":["rust","panic","integer-overflow","capacity","nucleo","lock-free"],"backgroundTag":"integer-overflow","analyzedSha":"15fe1318f1df51de604262eb50734c9883d48e7b","analyzedAt":"2026-08-19T08:56:57.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}