When trying to track down a vaddr-poisoning bug, I found that that the
secondary cache isn't emptied on test teardown. We should probably do
that to make the tests hermetic. Otherwise, repeating the tests lots of
times using --gtest_repeat fails after the mmap vaddr space is
exhausted.
To repro:
$ ninja check-scudo_standalone # build
$ ./projects/compiler-rt/lib/scudo/standalone/tests/ScudoUnitTest-x86_64-Test \
--gtest_filter=ScudoSecondaryTest.*:-ScudoSecondaryTest.SecondaryCombinations \
--gtest_repeat=10000
Reviewed By: cryptoad
Differential Revision: https://reviews.llvm.org/D102874
void unmapTestOnly() {
TSDRegistry.unmapTestOnly();
Primary.unmapTestOnly();
+ Secondary.unmapTestOnly();
#ifdef GWP_ASAN_HOOKS
if (getFlags()->GWP_ASAN_InstallSignalHandlers)
gwp_asan::segv_handler::uninstallSignalHandlers();
void enable() {}
void releaseToOS() {}
void disableMemoryTagging() {}
+ void unmapTestOnly() {}
bool setOption(Option O, UNUSED sptr Value) {
if (O == Option::ReleaseInterval || O == Option::MaxCacheEntriesCount ||
O == Option::MaxCacheEntrySize)
void enable() { Mutex.unlock(); }
+ void unmapTestOnly() { empty(); }
+
private:
void empty() {
struct {
void disableMemoryTagging() { Cache.disableMemoryTagging(); }
+ void unmapTestOnly() { Cache.unmapTestOnly(); }
+
private:
typename Config::SecondaryCache Cache;
scudo::ScopedString Str(1024);
L->getStats(&Str);
Str.output();
+ L->unmapTestOnly();
}
struct NoCacheConfig {
scudo::ScopedString Str(1024);
L->getStats(&Str);
Str.output();
+ L->unmapTestOnly();
}
TEST(ScudoSecondaryTest, SecondaryIterate) {
scudo::ScopedString Str(1024);
L->getStats(&Str);
Str.output();
+ L->unmapTestOnly();
}
TEST(ScudoSecondaryTest, SecondaryOptions) {
EXPECT_TRUE(L->setOption(scudo::Option::MaxCacheEntrySize, 1UL << 20));
EXPECT_TRUE(L->canCache(1UL << 16));
}
+ L->unmapTestOnly();
}
static std::mutex Mutex;
scudo::ScopedString Str(1024);
L->getStats(&Str);
Str.output();
+ L->unmapTestOnly();
}