From 7dd32e57273aae35f944aac8f31608a09a83ee40 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Mon, 2 Feb 2026 17:53:07 +0800 Subject: [PATCH] progress --- lib/system/alloc.nim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/system/alloc.nim b/lib/system/alloc.nim index c5e8e35466..cc760fd360 100644 --- a/lib/system/alloc.nim +++ b/lib/system/alloc.nim @@ -478,7 +478,8 @@ iterator allObjects(m: var MemRegion): pointer {.inline.} = a = a +% size else: let c = cast[PBigChunk](c) - yield addr(c.data) + # Yield the aligned address that was actually returned to user + yield addr(c.data) +! c.alignOffset m.locked = false proc iterToProc*(iter: typed, envType: typedesc; procName: untyped) {. @@ -1130,7 +1131,8 @@ when not defined(gcDestructors): if avlNode != nil: var k = cast[pointer](avlNode.key) var c = cast[PBigChunk](pageAddr(k)) - sysAssert(addr(c.data) == k, " k is not the same as addr(c.data)!") + # k should be the aligned address (addr(c.data) + alignOffset) + sysAssert(addr(c.data) +! c.alignOffset == k, " k is not the aligned address!") if cast[ptr FreeCell](k).zeroField >% 1: result = k sysAssert isAllocatedPtr(a, result), " result wrong pointer!"