[compiler-rt] [scudo] Update secondary cache time-based release logic. (PR #107507)

Joshua Baehring via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 12 15:43:49 PDT 2024


================
@@ -535,6 +533,9 @@ class MapAllocatorCache {
       Entries[LRUHead].Prev = static_cast<u16>(FreeIndex);
     }
 
+    if (LastUnreleasedEntry == CachedBlock::InvalidEntry)
+      LastUnreleasedEntry = static_cast<u16>(FreeIndex);
----------------
JoshuaMBa wrote:

Whoops, was running the tests on a branch with an older version of this and forgot to copy over the initialization of `LastUnreleasedEntry` to `CachedBlock::InvalidEntry`. Turns out that it still behaves correctly because `AvailableHead` is initialized to `0` so after the first insertion, `LastUnreleasedEntry` (which is initially `0`) already holds the correct value and then the program behaves normally. But we definitely shouldn't have this weird dependency on `AvailableHead`, and it is technically possible that someone calls `releaseToOS()` before the first insertion (in which case `LastUnreleasedEntry` would actually store the wrong value). 

https://github.com/llvm/llvm-project/pull/107507


More information about the llvm-commits mailing list