{"record":{"id":"c7221d411dba1708","repo":"GitoxideLabs/gitoxide","slug":"an-architecture-able-to-hold-32-bits-of-integer","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/access.rs","lineNumber":49,"sourceCode":"    /// Note that it is always conforming to the hash used in the owning repository.\n    pub fn object_hash(&self) -> gix_hash::Kind {\n        self.object_hash\n    }\n\n    /// Returns an object id at the given index in our list of (sorted) hashes.\n    /// The position ranges from 0 to `self.num_commits()`\n    // copied from gix-odb/src/pack/index/ext\n    pub fn id_at(&self, pos: file::Position) -> &gix_hash::oid {\n        assert!(\n            pos.0 < self.num_commits(),\n            \"expected lexicographical position less than {}, got {}\",\n            self.num_commits(),\n            pos.0\n        );\n        let pos: usize = pos\n            .0\n            .try_into()\n            .expect(\"an architecture able to hold 32 bits of integer\");\n        let start = self.oid_lookup_offset + (pos * self.hash_len);\n        gix_hash::oid::from_bytes_unchecked(&self.data[start..][..self.hash_len])\n    }\n\n    /// Return an iterator over all object hashes stored in the base graph.\n    pub fn iter_base_graph_ids(&self) -> impl Iterator<Item = &gix_hash::oid> {\n        let start = self.base_graphs_list_offset.unwrap_or(0);\n        let base_graphs_list = &self.data[start..][..self.hash_len * usize::from(self.base_graph_count)];\n        base_graphs_list\n            .chunks_exact(self.hash_len)\n            .map(gix_hash::oid::from_bytes_unchecked)\n    }\n\n    /// return an iterator over all commits in this file.\n    pub fn iter_commits(&self) -> impl Iterator<Item = Commit<'_>> {\n        (0..self.num_commits()).map(move |i| self.commit_at(file::Position(i)))\n    }\n","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-commitgraph/src/file/access.rs#L31-L67","documentation":"Commit graph positions (u32) are converted to usize for indexing into the OID lookup chunk. The expect asserts the platform's usize can hold all 32-bit positions. On a 16-bit target (where usize is smaller than u32) this panics; on all mainstream 64/32-bit platforms it cannot trigger for valid positions.","triggerScenarios":"Calling BaseGraphFile::id_at (directly or via iter_ids/lookup_inner) on an architecture where usize < 32 bits (e.g. embedded 16-bit targets).","commonSituations":"Compiling gitoxide for unusual embedded targets; not reachable on normal desktop/server platforms.","solutions":["Build/target a 64-bit (or at least 32-bit) platform","If 16-bit support is needed, handle the conversion fallibly instead of using id_at","Avoid using gix-commitgraph on platforms with 16-bit usize"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"// Compile-time/platform guard:\nconst _: () = assert!(std::mem::size_of::<usize>() >= 4, \"commitgraph requires 32-bit usize\");","typeGuard":"fn supports_u32_usize() -> bool { std::mem::size_of::<usize>() >= 4 }","tryCatchPattern":null,"preventionTips":["Gate gix-commitgraph behind a cfg check for pointer width on exotic targets","Target 64-bit platforms for git tooling","Avoid embedded 16-bit targets for this crate"],"tags":["panic","platform","usize","commitgraph"],"backgroundTag":"unsupported-platform","analyzedSha":"e73179060badf27222d790981fac3f84c1830a7e","analyzedAt":"2026-09-08T11:26:50.865Z","contentChangedAt":"2026-09-08T11:26:50.865Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}