fix(Generator): 补全 ClassGenBase 拆分遗漏的 17 个字段初始化
结构体由 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 字段。
This commit is contained in:
1 parent
d18f9a7e7f
commit
65838da0dc
1 file changed
+24
@@ -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
|
||||
|
||||
Reference in new issue
Block a user