From 46168302c8bd675ac89bc60e636edb207b157b78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20S=C3=A9chet?= Date: Wed, 23 Aug 2023 15:45:21 +0000 Subject: [PATCH] Have realloc ensure proper "pointerness" of allcoations. --- sdlib/d/gc/tcache.d | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sdlib/d/gc/tcache.d b/sdlib/d/gc/tcache.d index 223c4fd95..eee6d23e2 100644 --- a/sdlib/d/gc/tcache.d +++ b/sdlib/d/gc/tcache.d @@ -84,11 +84,12 @@ public: auto copySize = size; auto pd = getPageDescriptor(ptr); + auto samePointerness = containsPointers == pd.containsPointers; if (pd.isSlab()) { auto newSizeClass = getSizeClass(size); auto oldSizeClass = pd.sizeClass; - if (newSizeClass == oldSizeClass) { + if (samePointerness && newSizeClass == oldSizeClass) { return ptr; } @@ -100,7 +101,7 @@ public: copySize = min(size, pd.extent.usedCapacity); auto esize = pd.extent.size; - if (alignUp(size, PageSize) == esize) { + if (samePointerness && alignUp(size, PageSize) == esize) { pd.extent.setUsedCapacity(copySize); return ptr; } @@ -108,7 +109,6 @@ public: // TODO: Try to extend/shrink in place. } - containsPointers = (containsPointers | pd.containsPointers) != 0; auto newPtr = alloc(size, containsPointers); if (newPtr is null) { return null;