Skip to content

Commit c4c5113

Browse files
committed
[NFC][scudo] Restore !UseQuarantine check in tests
The check was removed in D99786 as it seems that quarantine is irrelevant for the just created allocator. However there is internal issues with tagged memory access. We should be able to fix iterateOverChunks for taggin later.
1 parent a2ea003 commit c4c5113

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

compiler-rt/lib/scudo/standalone/tests/combined_test.cpp

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -286,22 +286,27 @@ TYPED_TEST(ScudoCombinedTest, IterateOverChunks) {
286286
// Allocates a bunch of chunks, then iterate over all the chunks, ensuring
287287
// they are the ones we allocated. This requires the allocator to not have any
288288
// other allocated chunk at this point (eg: won't work with the Quarantine).
289-
std::vector<void *> V;
290-
for (scudo::uptr I = 0; I < 64U; I++)
291-
V.push_back(Allocator->allocate(
292-
rand() % (TypeParam::Primary::SizeClassMap::MaxSize / 2U), Origin));
293-
Allocator->disable();
294-
Allocator->iterateOverChunks(
295-
0U, static_cast<scudo::uptr>(SCUDO_MMAP_RANGE_SIZE - 1),
296-
[](uintptr_t Base, size_t Size, void *Arg) {
297-
std::vector<void *> *V = reinterpret_cast<std::vector<void *> *>(Arg);
298-
void *P = reinterpret_cast<void *>(Base);
299-
EXPECT_NE(std::find(V->begin(), V->end(), P), V->end());
300-
},
301-
reinterpret_cast<void *>(&V));
302-
Allocator->enable();
303-
for (auto P : V)
304-
Allocator->deallocate(P, Origin);
289+
// FIXME: Make it work with UseQuarantine and tagging enabled. Internals of
290+
// iterateOverChunks reads header by tagged and non-tagger pointers so one of
291+
// them will fail.
292+
if (!UseQuarantine) {
293+
std::vector<void *> V;
294+
for (scudo::uptr I = 0; I < 64U; I++)
295+
V.push_back(Allocator->allocate(
296+
rand() % (TypeParam::Primary::SizeClassMap::MaxSize / 2U), Origin));
297+
Allocator->disable();
298+
Allocator->iterateOverChunks(
299+
0U, static_cast<scudo::uptr>(SCUDO_MMAP_RANGE_SIZE - 1),
300+
[](uintptr_t Base, size_t Size, void *Arg) {
301+
std::vector<void *> *V = reinterpret_cast<std::vector<void *> *>(Arg);
302+
void *P = reinterpret_cast<void *>(Base);
303+
EXPECT_NE(std::find(V->begin(), V->end(), P), V->end());
304+
},
305+
reinterpret_cast<void *>(&V));
306+
Allocator->enable();
307+
for (auto P : V)
308+
Allocator->deallocate(P, Origin);
309+
}
305310
}
306311

307312
TYPED_TEST(ScudoCombinedTest, UseAfterFree) {

0 commit comments

Comments
 (0)