diff options
author | SirOlaf <34164198+SirOlaf@users.noreply.github.com> | 2024-07-08 11:15:53 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-08 11:15:53 +0200 |
commit | 3f5016f60e3ce7fd5c2883cf65dbbc9fbdbf9300 (patch) | |
tree | a4ea24063895feb6e3cd89f114c61ec5acbc437c | |
parent | 4faa15f3ad6504c3ba808e63ecd729d3fc3cb78a (diff) | |
download | Nim-3f5016f60e3ce7fd5c2883cf65dbbc9fbdbf9300.tar.gz |
Adjust the correct chunk's free space in allocator (#23795)
Fixes #23788
-rw-r--r-- | lib/system/alloc.nim | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/system/alloc.nim b/lib/system/alloc.nim index cc4a24d8f..94c747e0b 100644 --- a/lib/system/alloc.nim +++ b/lib/system/alloc.nim @@ -865,7 +865,7 @@ proc rawAlloc(a: var MemRegion, requestedSize: int): pointer = when not defined(gcDestructors): sysAssert(c.freeList.zeroField == 0, "rawAlloc 8") c.freeList = c.freeList.next - dec(c.free, size) + dec(cast[PSmallChunk](pageAddr(result)).free, size) sysAssert((cast[int](result) and (MemAlign-1)) == 0, "rawAlloc 9") sysAssert(allocInv(a), "rawAlloc: end c != nil") sysAssert(allocInv(a), "rawAlloc: before c.free < size") @@ -948,7 +948,7 @@ proc rawDealloc(a: var MemRegion, p: pointer) = inc(c.free, s) else: inc(c.free, s) - if c.free == SmallChunkSize-smallChunkOverhead(): + if c.free == SmallChunkSize-smallChunkOverhead() and a.freeSmallChunks[s div MemAlign] == c: listRemove(a.freeSmallChunks[s div MemAlign], c) c.size = SmallChunkSize freeBigChunk(a, cast[PBigChunk](c)) |