{"record":{"id":"15474701a1b52411","repo":"GitoxideLabs/gitoxide","slug":"an-architecture-able-to-hold-32-bits-of-integer-154747","errorCode":null,"errorMessage":"an architecture able to hold 32 bits of integer","messagePattern":"an architecture able to hold 32 bits of integer","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"info","filePath":"gix-commitgraph/src/file/commit.rs","lineNumber":154,"sourceCode":"                    ))),\n                },\n                ParentEdge::GraphPosition(pos) => {\n                    self.state = ParentIteratorState::Second;\n                    Some(Ok(pos))\n                }\n                ParentEdge::ExtraEdgeIndex(_) => Some(Err(message!(\n                    \"commit {}'s first parent is an extra edge index, which is invalid\",\n                    self.commit_data.id(),\n                ))),\n            },\n            ParentIteratorState::Second => match self.commit_data.parent2 {\n                ParentEdge::None => None,\n                ParentEdge::GraphPosition(pos) => Some(Ok(pos)),\n                ParentEdge::ExtraEdgeIndex(extra_edge_index) => {\n                    if let Some(extra_edges_list) = self.commit_data.file.extra_edges_data() {\n                        let start_offset: usize = extra_edge_index\n                            .try_into()\n                            .expect(\"an architecture able to hold 32 bits of integer\");\n                        let start_offset = start_offset\n                            .checked_mul(4)\n                            .expect(\"an extended edge index small enough to fit in usize\");\n                        if let Some(tail) = extra_edges_list.get(start_offset..) {\n                            self.state = ParentIteratorState::Extra(tail.chunks(4));\n                            // This recursive call is what blocks me from replacing ParentIterator\n                            // with a std::iter::from_fn closure.\n                            self.next()\n                        } else {\n                            Some(Err(message!(\n                                \"commit {}'s extra edges overflows the commit-graph file's extra edges list\",\n                                self.commit_data.id()\n                            )))\n                        }\n                    } else {\n                        Some(Err(message!(\n                            \"commit {} has extra edges, but commit-graph file has no extra edges list\",\n                            self.commit_data.id()","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-commitgraph/src/file/commit.rs#L136-L172","documentation":"When walking parents, an extended (extra) edge index (u32 from the EDGE chunk) is converted to usize and then multiplied by 4 to get the byte offset. The first expect panics if usize can't hold the 32-bit index (16-bit platforms); the second guards multiplication overflow. It appears in the recursive next() of the parent iterator.","triggerScenarios":"Iterating parents of a commit in a commit-graph file with an Extra Edge List on a platform where usize < u32, or with an index so large that *4 overflows usize (essentially only 16-bit or contrived cases).","commonSituations":"Corrupted commit-graph files with bogus extra-edge indices combined with small-address-space targets; not reachable on normal 64-bit systems.","solutions":["Use a 64-bit platform","Regenerate the commit-graph file (git commit-graph write) if it may be corrupt","Use a fallible conversion and propagate an error instead of expecting","Update gix-commitgraph if overflow handling should be graceful"],"exampleFix":"// before\nlet start_offset: usize = extra_edge_index\n    .try_into()\n    .expect(\"an architecture able to hold 32 bits of integer\");\n// after\nlet start_offset: usize = extra_edge_index\n    .try_into()\n    .map_err(|_| message(\"extra edge index does not fit into usize\"))?;","handlingStrategy":"type-guard","validationCode":"const _: () = assert!(std::mem::size_of::<usize>() >= 4, \"extra-edge iteration requires 32-bit usize\");","typeGuard":"fn can_hold_u32() -> bool { std::mem::size_of::<usize>() >= 4 }","tryCatchPattern":null,"preventionTips":["Use 64-bit platforms for commit-graph traversal","Regenerate corrupt commit-graph files before use","Prefer fallible try_into + error propagation in custom forks"],"tags":["panic","platform","commitgraph","overflow"],"backgroundTag":"value-out-of-range","analyzedSha":"e73179060badf27222d790981fac3f84c1830a7e","analyzedAt":"2026-09-08T11:26:50.865Z","contentChangedAt":"2026-09-08T11:26:50.865Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}