diff --git a/compiler-rt/lib/scudo/standalone/size_class_map.h b/compiler-rt/lib/scudo/standalone/size_class_map.h --- a/compiler-rt/lib/scudo/standalone/size_class_map.h +++ b/compiler-rt/lib/scudo/standalone/size_class_map.h @@ -318,7 +318,7 @@ static const uptr MinSizeLog = 7; static const uptr MidSizeLog = 7; static const uptr MaxSizeLog = 7; - static const u16 MaxNumCachedHint = 8; + static const u16 MaxNumCachedHint = 12; static const uptr MaxBytesCachedLog = 10; static const uptr SizeDelta = 0; }; diff --git a/compiler-rt/lib/scudo/standalone/tests/combined_test.cpp b/compiler-rt/lib/scudo/standalone/tests/combined_test.cpp --- a/compiler-rt/lib/scudo/standalone/tests/combined_test.cpp +++ b/compiler-rt/lib/scudo/standalone/tests/combined_test.cpp @@ -10,6 +10,7 @@ #include "tests/scudo_unit_test.h" #include "allocator_config.h" +#include "chunk.h" #include "combined.h" #include @@ -700,3 +701,33 @@ Allocator->deallocate(Ptrs[i], Origin); } } + +#if SCUDO_CAN_USE_PRIMARY64 +#if SCUDO_TRUSTY + +// TrustyConfig is designed for a domain-specific allocator. Add a basic test +// which covers only simple operations and ensure the configuration is able to +// compile. +TEST(ScudoCombinedTest, BasicTrustyConfig) { + using AllocatorT = scudo::Allocator; + auto Allocator = std::unique_ptr(new AllocatorT()); + + for (scudo::uptr ClassId = 1U; + ClassId <= scudo::TrustyConfig::SizeClassMap::LargestClassId; + ClassId++) { + const scudo::uptr Size = + scudo::TrustyConfig::SizeClassMap::getSizeByClassId(ClassId); + void *p = Allocator->allocate(Size - scudo::Chunk::getHeaderSize(), Origin); + ASSERT_NE(p, nullptr); + free(p); + } + + bool UnlockRequired; + auto *TSD = Allocator->getTSDRegistry()->getTSDAndLock(&UnlockRequired); + TSD->Cache.drain(); + + Allocator->releaseToOS(); +} + +#endif +#endif