diff --git a/includes/memhub.vp b/includes/memhub.vp index c198ec5..1745e31 100644 --- a/includes/memhub.vp +++ b/includes/memhub.vp @@ -668,6 +668,20 @@ class MemBuddy(MemManager): m_t_d: t.CUInt16T | t.CPtr = (t.CUInt16T | t.CPtr)(t.CVoid(tail_d, t.CPtr)) m_t_d[0] = t.CUInt16T(MEMBUDDY_DET_MARKER) if self._det_records is not None: + # 分配重叠即时检测:新块地址是否已在 active 记录(同一块重复 + # 分配实锤——SlotsBugTest 7B buf 与 72B Token 同 ptr、cargs + # 只写 0/40 根因)。重叠 = MemBuddy free list 损坏(active 块 + # 混入 free list),在第一次重叠处拦截并打印两个 size。 + ff_d: t.CUInt64T = t.CUInt64T(1) << 63 + dup_i: t.CSizeT = 0 + while dup_i < self._det_count: + drp: t.CUInt64T = self._det_records[dup_i * 2] + drs: t.CUInt64T = self._det_records[dup_i * 2 + 1] + if drp == base_ret_d + 2 and (drs & ff_d) == 0: + stdio.printf("[DET] 分配重叠: 新alloc(size=%llu)与记录[%zu](sz=%llu)同地址 ptr=%llu(同一块重复分配,free list 损坏)\n", + t.CUInt64T(size), dup_i, drs & (ff_d - 1), base_ret_d + 2) + stdlib.exit(1) + dup_i += 1 if self._det_count >= self._det_cap: # 记录表满:stdlib.realloc 翻倍扩容(防 is_alive/_det_probe # 因容量耗尽漏检——SlotsBugTest 编译 includes 超 2M 次 alloc,