diff options
| author | Stefan Boberg <[email protected]> | 2025-10-06 13:37:10 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2025-10-06 13:37:10 +0200 |
| commit | def0cedced860e12235d34403993011222fa80b6 (patch) | |
| tree | c8a727fa68114cc29a5dbea2b77a704a87b38725 /src/zenstore/compactcas.cpp | |
| parent | added Hidden option to oidctoken creation with oidc token exe (#556) (diff) | |
| download | zen-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.cpp | 7 |
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()); }; { |