From 65838da0dca81d59aa2376b2ccbfb64c9f9b1abc Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Tue, 18 Aug 2026 12:40:21 +0800 Subject: [PATCH] =?UTF-8?q?fix(Generator):=20=E8=A1=A5=E5=85=A8=20ClassGen?= =?UTF-8?q?Base=20=E6=8B=86=E5=88=86=E9=81=97=E6=BC=8F=E7=9A=84=2017=20?= =?UTF-8?q?=E4=B8=AA=E5=AD=97=E6=AE=B5=E5=88=9D=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 结构体由 mb.alloc 分配,未初始化字段是内存垃圾。异常表字段(ExceptionCount/ExceptionNames/ExceptionParents/ExceptionCodes/NextExceptionCode/_exception_codes_tmp_count)此前未初始化,无用户异常类的项目(如 FuncTest)从不触发 _ensure_exception_tables 懒分配,is_exception_name 里非 null 垃圾指针通过 is not None 检查后 strcmp 越界(ASAN heap-buffer-overflow)。一并补上 RenumAliasTy/RenumAliasVariant/ClassMeta 4 个/Decorator 4 个/GenericSpecDepth 字段。 --- App/lib/core/Gen/Generator.vp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/App/lib/core/Gen/Generator.vp b/App/lib/core/Gen/Generator.vp index 47c74a6..8708d23 100644 --- a/App/lib/core/Gen/Generator.vp +++ b/App/lib/core/Gen/Generator.vp @@ -180,6 +180,30 @@ class Generator(BaseGenMixin.BaseGenMixin, TypeGenMixin.TypeGenMixin, self.VtMethodNames = None self.VtParentSha1s = None self.VtMethodCount = 0 + # ---- ClassGenBase 补漏字段(阶段 D 拆分新增,此前未初始化: + # 结构体是 malloc 分配,未初始化字段是内存垃圾——非 null 垃圾 + # 指针能通过 `is not None` 检查,导致 is_exception_name 等查询 + # 直接 strcmp 越界崩溃;int 垃圾则导致循环次数失控) ---- + self.RenumAliasTy = None + self.RenumAliasVariant = None + self.ClassMetaKinds = None + self.ClassMetaClss = None + self.ClassMetaFields = None + self.ClassMetaCount = 0 + self.DecoratorFuncCount = 0 + self.DecoratorFuncNames = None + self.DecoratorWrapNames = None + self.DecoratorArgs = None + # 异常类注册表(_ensure_exception_tables 仍保留懒分配,但 + # ExceptionNames 必须初始化为 null——否则 `is not None` 误判垃圾 + # 指针为已初始化,跳过分配直接查表 → strcmp 越界) + self.ExceptionCount = 0 + self.ExceptionNames = None + self.ExceptionParents = None + self.ExceptionCodes = None + self.NextExceptionCode = 0 + self._exception_codes_tmp_count = 0 + self.GenericSpecDepth = 0 # ---- ImportsGenMixin 字段 ---- self.ReexportSha1s = None self.ReexportFuncs = None