aboutsummaryrefslogtreecommitdiff
path: root/src/zenstore/compactcas.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2025-10-06 13:37:10 +0200
committerGitHub Enterprise <[email protected]>2025-10-06 13:37:10 +0200
commitdef0cedced860e12235d34403993011222fa80b6 (patch)
treec8a727fa68114cc29a5dbea2b77a704a87b38725 /src/zenstore/compactcas.cpp
parentadded Hidden option to oidctoken creation with oidc token exe (#556) (diff)
downloadzen-def0cedced860e12235d34403993011222fa80b6.tar.xz
zen-def0cedced860e12235d34403993011222fa80b6.zip
fixed issue in compactcas.restart test due to std::vector<bool> (#559)
`std::vector<bool>` is a special container since it bit packs the values rather than just using an array of booleans. This means that updating it on multiple threads simultaneously is dangerous
Diffstat (limited to 'src/zenstore/compactcas.cpp')
-rw-r--r--src/zenstore/compactcas.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/zenstore/compactcas.cpp b/src/zenstore/compactcas.cpp
index 14ef2a15d..5cc4dad54 100644
--- a/src/zenstore/compactcas.cpp
+++ b/src/zenstore/compactcas.cpp
@@ -1794,7 +1794,9 @@ TEST_CASE("compactcas.restart")
Hashes.reserve(kChunkCount);
auto ValidateChunks = [&](CasContainerStrategy& Cas, std::span<const IoHash> Hashes, bool ShouldExist) {
- std::vector<bool> Exists(Hashes.size(), false);
+ // It's important to not use std::vector<bool> here as that is not safe to use from multiple threads
+ // due to its non-atomic updates using bit masking
+ std::vector<uint8_t> Exists(Hashes.size(), false);
Cas.IterateChunks(
Hashes,
[&](size_t Index, const IoBuffer& Buffer) -> bool {
@@ -1816,7 +1818,8 @@ TEST_CASE("compactcas.restart")
},
&ThreadPool,
1u * 1248u);
- CHECK_EQ(std::find(Exists.begin(), Exists.end(), !ShouldExist), Exists.end());
+
+ CHECK_EQ(std::find(Exists.begin(), Exists.end(), !ShouldExist ? 1 : 0), Exists.end());
};
{