GitoxideLabs/gitoxide · error
base graph count to fit in 32-bits
Error message
base graph count to fit in 32-bits
What it means
When initializing a commit-graph File, the BASE_GRAPHS_LIST chunk size divided by the hash length must fit into a u32, since the count of base graphs is a 32-bit quantity in the format. The `try_into()` is expected to succeed because the chunk is already validated. This panic means the chunk file is structurally corrupt or the header/base-graph count disagrees in an unexpected way.
Solutions
- Delete and regenerate the commit-graph: `rm .git/objects/info/commit-graph* && git commit-graph write`
- Validate the commit-graph file before use; treat unreadable graphs as optional and fall back to object parsing
- Report upstream if reproducible with a valid git-generated commit-graph
Example fix
// before
let f = gix_commitgraph::File::at(path, hash)?;
// after (guard at call site)
let f = if path.exists() { gix_commitgraph::File::at(path, hash).ok() } else { None }; Defensive patterns
Strategy: fallback
Validate before calling
// verify chunk sizes before trusting the file
if file_len < expected_min_len { skip_commitgraph(); } Try / catch
let graph = gix_commitgraph::File::at(path, hash).map_err(|e| e.into_error()).ok();
Prevention
- Never treat commit-graph load failure as fatal — it is a performance cache
- Regenerate commit-graphs after git version upgrades
- Sanity-check commit-graph file size before opening
When it happens
Trigger: Calling `gix_commitgraph::File::at()` (public `new`) on a commit-graph file whose BASE_GRAPHS_LIST chunk is larger than u32::MAX hash entries — i.e. a corrupt or adversarially crafted commit-graph file.
Common situations: Reading a corrupted or hand-crafted commit-graph file; a repository with a malformed .git/objects/info/commit-graph; fuzzing targets; a git version producing non-standard graphs.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- number of commits in CDAT chunk to fit in 32 bits
- an architecture able to hold 32 bits of integer
- ' ' is not a valid configuration key
- Cannot use iter_v1() on index of type
- Cannot use iter_v2() on index of type
AI-assisted analysis of GitoxideLabs/gitoxide@e73179060b (2026-09-08).
Data as JSON: /api/errors/c4f7d2671be31a1d.
Report an issue: GitHub.
Appendix: source
Thrown at gix-commitgraph/src/file/init.rs:78
let chunks = gix_chunk::file::Index::from_bytes(&data, ofs, u32::from(chunk_count))
.or_raise(|| message!("Couldn't read commit-graph file with {chunk_count} chunks at offset {ofs}"))?;
let base_graphs_list_offset = chunks
.validated_usize_offset_by_id(BASE_GRAPHS_LIST_CHUNK_ID, |chunk_range| {
let chunk_size = chunk_range.len();
if chunk_size % object_hash.len_in_bytes() != 0 {
return Err(message!("Commit-graph chunk {BASE_GRAPHS_LIST_CHUNK_ID:?} has invalid size: {msg}",
msg = format!(
"chunk size {} is not a multiple of {}",
chunk_size,
object_hash.len_in_bytes()
),
).raise());
}
let chunk_base_graph_count: u32 = (chunk_size / object_hash.len_in_bytes())
.try_into()
.expect("base graph count to fit in 32-bits");
if chunk_base_graph_count != u32::from(base_graph_count) {
return Err(message!("Commit-graph {BASE_GRAPHS_LIST_CHUNK_ID:?} chunk contains {chunk_base_graph_count} base graphs, but commit-graph file header claims {base_graph_count} base graphs").raise())
}
Ok(chunk_range.start)
})
.ok()
.transpose()?;
let (commit_data_offset, commit_data_count): (_, u32) = chunks
.validated_usize_offset_by_id(COMMIT_DATA_CHUNK_ID, |chunk_range| {
let chunk_size = chunk_range.len();
let entry_size = object_hash.len_in_bytes() + COMMIT_DATA_ENTRY_SIZE_SANS_HASH;
if chunk_size % entry_size != 0 {
return Err(message!("Commit-graph chunk {COMMIT_DATA_CHUNK_ID:?} has invalid size: chunk size {chunk_size} is not a multiple of {entry_size}").raise())
}
Ok((
chunk_range.start,View on GitHub (pinned to e73179060b)