From 034293df594f4a429ce3e4248866b27095eef440 Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Sat, 10 Oct 2026 14:27:00 +0800 Subject: [PATCH] =?UTF-8?q?fix(gen):=20freed=5Frestore/freed=5Fjoin/freed?= =?UTF-8?q?=5Fcapture=20=E8=A1=A5=20global=20=E5=A3=B0=E6=98=8E=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=87=8E=E5=86=99=E5=B4=A9=E6=BA=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 上一提交(eea8111)在 freed_restore 里重新赋值全局指针 _g_freed_slots 却未声明 global,被解析成未初始化的局部变量:is None 判假 → 跳过分配 → 对垃圾地址(0x11)野写,ASan access-violation。为三个新函数统一声明 global _g_freed_slots, _g_freed_count(与 _FreedMark 同口径)。 --- App/lib/core/Gen/VarGenMixin.vp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/App/lib/core/Gen/VarGenMixin.vp b/App/lib/core/Gen/VarGenMixin.vp index 6beea47..a69f596 100644 --- a/App/lib/core/Gen/VarGenMixin.vp +++ b/App/lib/core/Gen/VarGenMixin.vp @@ -374,6 +374,7 @@ novirtual class VarGenMixin: # 路径都失效,才算失效"(求交),与 life_* 的 Meet 同点位、同生命周期(pool 快照)。 def freed_capture(self, trans: HT.Translator*) -> sizet*: """快照当前失效槽表:buf[0]=count,其后每项一个失效槽指针;失败返回 None""" + global _g_freed_slots, _g_freed_count if trans is None or trans.Pool is None: return None pool: memhub.MemBuddy* = trans.Pool n: sizet = sizet(_g_freed_count) @@ -388,7 +389,7 @@ novirtual class VarGenMixin: def freed_restore(self, buf: sizet*) -> int: """把失效槽表复位到快照(分支出口 / 单侧到达合流时用);0=完成 / 1=无快照""" - global _g_freed_count + global _g_freed_slots, _g_freed_count if buf is None: return 1 n: sizet = buf[0] if n > 0: @@ -404,7 +405,7 @@ novirtual class VarGenMixin: def freed_join(self, buf: sizet*) -> int: """合流:当前失效槽表与快照**求交**(只有两路都失效才算失效);0=完成 / 1=无快照""" - global _g_freed_count + global _g_freed_slots, _g_freed_count if buf is None: return 1 n: sizet = buf[0] out: int = 0