diff --git a/compiler-rt/lib/scudo/standalone/secondary.h b/compiler-rt/lib/scudo/standalone/secondary.h --- a/compiler-rt/lib/scudo/standalone/secondary.h +++ b/compiler-rt/lib/scudo/standalone/secondary.h @@ -75,11 +75,6 @@ s32 MaxReleaseToOsIntervalMs = INT32_MAX> class MapAllocatorCache { public: - // Fuchsia doesn't allow releasing Secondary blocks yet. Note that 0 length - // arrays are an extension for some compilers. - // FIXME(kostyak): support (partially) the cache on Fuchsia. - static_assert(!SCUDO_FUCHSIA || EntriesArraySize == 0U, ""); - // Ensure the default maximum specified fits the array. static_assert(DefaultMaxEntriesCount <= EntriesArraySize, ""); @@ -225,9 +220,10 @@ for (uptr I = 0; I < EntriesArraySize; I++) { if (!Entries[I].Block || !Entries[I].Time || Entries[I].Time > Time) continue; - releasePagesToOS(Entries[I].Block, 0, - Entries[I].BlockEnd - Entries[I].Block, - &Entries[I].Data); + const uptr Base = Entries[I].MapBase; + const uptr Offset = Entries[I].Block - Entries[I].MapBase; + const uptr Size = Entries[I].BlockEnd - Entries[I].Block; + releasePagesToOS(Base, Offset, Size, &Entries[I].Data); Entries[I].Time = 0; } } @@ -392,9 +388,9 @@ } const uptr CommitSize = MapEnd - PageSize - CommitBase; - const uptr Ptr = - reinterpret_cast(map(reinterpret_cast(CommitBase), - CommitSize, "scudo:secondary", 0, &Data)); + const uptr Ptr = reinterpret_cast( + map(reinterpret_cast(CommitBase), CommitSize, "scudo:secondary", + MAP_RESIZABLE, &Data)); LargeBlock::Header *H = reinterpret_cast(Ptr); H->MapBase = MapBase; H->MapSize = MapEnd - MapBase; diff --git a/compiler-rt/lib/scudo/standalone/tests/secondary_test.cpp b/compiler-rt/lib/scudo/standalone/tests/secondary_test.cpp --- a/compiler-rt/lib/scudo/standalone/tests/secondary_test.cpp +++ b/compiler-rt/lib/scudo/standalone/tests/secondary_test.cpp @@ -56,18 +56,12 @@ TEST(ScudoSecondaryTest, SecondaryBasic) { testSecondaryBasic>(); -#if !SCUDO_FUCHSIA testSecondaryBasic>>(); testSecondaryBasic< scudo::MapAllocator>>(); -#endif } -#if SCUDO_FUCHSIA -using LargeAllocator = scudo::MapAllocator; -#else using LargeAllocator = scudo::MapAllocator>; -#endif // This exercises a variety of combinations of size and alignment for the // MapAllocator. The size computation done here mimic the ones done by the