GitoxideLabs/gitoxide · info

an architecture able to hold 32 bits of integer

Error message

an architecture able to hold 32 bits of integer

What it means

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.

Solutions

  1. Build/target a 64-bit (or at least 32-bit) platform
  2. If 16-bit support is needed, handle the conversion fallibly instead of using id_at
  3. Avoid using gix-commitgraph on platforms with 16-bit usize
Defensive patterns

Strategy: type-guard

Validate before calling

// Compile-time/platform guard:
const _: () = assert!(std::mem::size_of::<usize>() >= 4, "commitgraph requires 32-bit usize");

Type guard

fn supports_u32_usize() -> bool { std::mem::size_of::<usize>() >= 4 }

Prevention

When it happens

Trigger: Calling BaseGraphFile::id_at (directly or via iter_ids/lookup_inner) on an architecture where usize < 32 bits (e.g. embedded 16-bit targets).

Common situations: Compiling gitoxide for unusual embedded targets; not reachable on normal desktop/server platforms.

Understand the failure class

Background: "unsupported platform" / "not supported on this platform" errors: what they mean and how to fix them — this error's family across 47 libraries.

Related errors


AI-assisted analysis of GitoxideLabs/gitoxide@e73179060b (2026-09-08). Data as JSON: /api/errors/c7221d411dba1708. Report an issue: GitHub.

Appendix: source

Thrown at gix-commitgraph/src/file/access.rs:49

    /// Note that it is always conforming to the hash used in the owning repository.
    pub fn object_hash(&self) -> gix_hash::Kind {
        self.object_hash
    }

    /// Returns an object id at the given index in our list of (sorted) hashes.
    /// The position ranges from 0 to `self.num_commits()`
    // copied from gix-odb/src/pack/index/ext
    pub fn id_at(&self, pos: file::Position) -> &gix_hash::oid {
        assert!(
            pos.0 < self.num_commits(),
            "expected lexicographical position less than {}, got {}",
            self.num_commits(),
            pos.0
        );
        let pos: usize = pos
            .0
            .try_into()
            .expect("an architecture able to hold 32 bits of integer");
        let start = self.oid_lookup_offset + (pos * self.hash_len);
        gix_hash::oid::from_bytes_unchecked(&self.data[start..][..self.hash_len])
    }

    /// Return an iterator over all object hashes stored in the base graph.
    pub fn iter_base_graph_ids(&self) -> impl Iterator<Item = &gix_hash::oid> {
        let start = self.base_graphs_list_offset.unwrap_or(0);
        let base_graphs_list = &self.data[start..][..self.hash_len * usize::from(self.base_graph_count)];
        base_graphs_list
            .chunks_exact(self.hash_len)
            .map(gix_hash::oid::from_bytes_unchecked)
    }

    /// return an iterator over all commits in this file.
    pub fn iter_commits(&self) -> impl Iterator<Item = Commit<'_>> {
        (0..self.num_commits()).map(move |i| self.commit_at(file::Position(i)))
    }

View on GitHub (pinned to e73179060b)