Skip to content

fix: use AtomicUsize for AsyncStatus generation counter (#3045) - #3047

Open
santhiprakash wants to merge 1 commit into
gitui-org:masterfrom
santhiprakash:fix/3045-atomic-usize-32bit
Open

santhiprakash wants to merge 1 commit into
gitui-org:masterfrom
santhiprakash:fix/3045-atomic-usize-32bit

Conversation

@santhiprakash

@santhiprakash santhiprakash commented Oct 27, 2026 •

Copy link
Copy Markdown

This Pull Request fixes/closes #3045.

It changes the following:

  • AsyncStatus::generation (the status cache-invalidation counter) now uses std::sync::atomic::AtomicUsize instead of AtomicU64, which only exists on targets with 64-bit atomics and therefore broke the build on 32-bit targets (reported on powerpc-apple-darwin; i686-unknown-linux-gnu and friends fail the same way).

I followed the checklist:

  • I added unittests
  • I ran make check without errors
  • I tested the overall application
  • I added an appropriate item to the changelog

Root cause

The generation counter is only a cache-invalidation token: it is loaded with Ordering::Relaxed, folded into the request key via hash(&(params, generation)), and bumped with fetch_add(1, Ordering::Relaxed) after each completed fetch. crate::hash is generic over T: Hash and produces the u64 request key through DefaultHasher::finish(), so nothing downstream assumes the counter is 64 bits wide.

Fix

Switched the counter to AtomicUsize — pointer-width atomics are available on every supported target, and the sibling pending field in the same struct already uses it. No new dependency is needed. A theoretical wrap at 2^32 on 32-bit targets is benign since the value is only an opaque token in the request hash. No behaviour change on 64-bit targets.

Verification

There is no 32-bit CI job, so I verified against a real 32-bit target (powerpc-unknown-linux-gnu, same class as the reporter's powerpc-apple-darwin):

  • before: cargo check --target powerpc-unknown-linux-gnu -p asyncgit fails with error[E0432]: unresolved import std::sync::atomic::AtomicU64 at asyncgit/src/status.rs:13
  • after: the same command checks asyncgit cleanly
  • make check green: cargo fmt --check, cargo clippy --workspace --all-features, cargo nextest run --workspace (318/318 passed), tombi format --check, cargo deny check
  • CI: the full workflow matrix (22 jobs: ubuntu/macos/windows × nightly/stable/1.88, plus lints/udeps/musl/arm/apple-x86 builds) passes on my fork: https://github.com/santhiprakash/gitui/actions/runs/40570456408 — the upstream run is awaiting the usual first-time-contributor approval

No unit tests were added since the change is a type substitution with identical runtime semantics; the existing workspace test suite continues to pass.

@santhiprakash
santhiprakash marked this pull request as ready for review October 27, 2026 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unconditional usage of 8-byte atomics breaks 32-bit build: status.rs: error:0: Unable to resolve use target ::"std-0_0_0"::sync::atomic::AtomicU64/*?*/

1 participant