Skip to content

Fix NarInfoDiskCache::queryCacheRaw on 32 bit platforms#15356

Merged
Ericson2314 merged 2 commits intomasterfrom
fix-i686-unsigned-promotion-narinfo-disk-cache
Feb 26, 2026
Merged

Fix NarInfoDiskCache::queryCacheRaw on 32 bit platforms#15356
Ericson2314 merged 2 commits intomasterfrom
fix-i686-unsigned-promotion-narinfo-disk-cache

Conversation

@xokdvium
Copy link
Contributor

Motivation

Bug has existed for a long time, but was only recently surfaced by 6733f2e. time_t was being implicitly promoted to unsigned. Apparently time_t is still 32 bit for i686-linux in nixpkgs.

Context

Fixes https://hydra.nixos.org/build/322992746/nixlog/1


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

@xokdvium xokdvium requested a review from edolstra February 26, 2026 20:58
@xokdvium xokdvium force-pushed the fix-i686-unsigned-promotion-narinfo-disk-cache branch from f6e6764 to f36278b Compare February 26, 2026 21:14
Bug has existed for a long time, but was only recently surfaced by
6733f2e. time_t was being implicitly promoted
to unsigned. Apparently time_t is still 32 bit for i686-linux in nixpkgs.

Fixes https://hydra.nixos.org/build/322992746/nixlog/1
Use proper nullptr literal for NULL pointer instead of the rather confusing 0
literal.
@xokdvium xokdvium force-pushed the fix-i686-unsigned-promotion-narinfo-disk-cache branch from f36278b to 796f5cd Compare February 26, 2026 21:18
@github-actions github-actions bot added store Issues and pull requests concerning the Nix store fetching Networking with the outside (non-Nix) world, input locking labels Feb 26, 2026
/* Important: always use int64_t even on 32 bit systems. Otherwise
the the subtraction would promote time_t to unsigned if time_t is
32 bit. */
auto timestamp = static_cast<int64_t>(time(nullptr)) - static_cast<int64_t>(settings.ttlMeta.get());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think being extra explicit here is nice. C/C++ integral promotion rules are too confusing to get right.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally agreed

@Ericson2314 Ericson2314 added this pull request to the merge queue Feb 26, 2026
Merged via the queue into master with commit 69d86ce Feb 26, 2026
19 checks passed
@Ericson2314 Ericson2314 deleted the fix-i686-unsigned-promotion-narinfo-disk-cache branch February 26, 2026 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fetching Networking with the outside (non-Nix) world, input locking store Issues and pull requests concerning the Nix store

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants