Skip to content

Commit 8fc9328

Browse files
committed
fix(provisioning): stamp key uses uint64_t, not size_t
一个 32 位宿主会把 64 位的 FNV offset basis 截断,于是它拥有一份与别人不同的键空间 而没有任何东西说明为什么。碰撞本身两侧都不是正确性问题 —— 记号文件存的是**列表**, 比较也是针对内容的,所以两个共键的列表会重新供给而不是悄悄采用对方的记录。
1 parent 39ab49e commit 8fc9328

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/build/prepare.cppm

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3257,8 +3257,15 @@ prepare_build(bool print_fingerprint,
32573257
// blocked on `resolve_xpkg_path` requiring `<name>@<version>`
32583258
// while a manifest is entitled to name a package unpinned.
32593259
const auto stampDir = mcpp::home::root() / "provisioned";
3260+
// `std::uint64_t`, not `std::size_t`: the offset basis below is
3261+
// a 64-bit constant and a 32-bit host would truncate it, giving
3262+
// that host a different key space for no reason anyone could
3263+
// see. A collision is not a correctness problem either way —
3264+
// the file stores the LIST and the comparison below is against
3265+
// its content, so two lists sharing a key re-provision rather
3266+
// than silently adopt each other's record.
32603267
auto stamp_key = [&] {
3261-
std::size_t h = 1469598103934665603ull; // FNV-1a
3268+
std::uint64_t h = 1469598103934665603ull; // FNV-1a
32623269
for (auto const& d : declaredDeps)
32633270
for (unsigned char ch : d + "\n")
32643271
{ h ^= ch; h *= 1099511628211ull; }

0 commit comments

Comments
 (0)