TermiNexus
1b2324edab
fix(transpyv): 修正 mark_module_class 的表生命周期(ASan 悬空键崩溃)
类别:a(编译器缺陷 —— 上一提交自引入的跨文件悬空 HashTable)
现场:ASan access-violation(READ @0x1),rcx=0x1
string.strcmp (includes/string.vp:86)
→ HashTable._find_slot (_resize) → __setitem__ → set_int
→ StructGenMixin.mark_module_class → ClassGenDef.translate_class_def
→ TranslatorGenMixin.translate_children → Translator.translate → RunPhase1 → main
根因:`ModuleClasses` 原先在 `mark_module_class` 里**懒创建**,并长期挂在 Gen 上;
表体与键都取自当次文件的 pool,而 pool 在文件/遍切换时会被 reset ⇒ 下一个文件里
`_resize` 重新散列旧键时 strcmp 读到已回收内存(0x1)⇒ 崩溃。
改动(与既有 `VisibleStructs` 同口径:表与键同池、同文件生命周期):
1. `ModuleClasses` 改由 `reset_visible_structs`(每文件翻译前调用)**无条件新建**
(不再区分 strict 分支),与键同池 ⇒ 无悬空。
2. `CurDefModuleSha1` 指向 `trans.ModuleSha1`(同一 pool 的串),同样在该函数里
清空,避免下一次 strcat/strcmp 读已回收内存。
3. `mark_module_class` 不再懒建表:池或表缺失时只记 `CurDefModuleSha1`、跳过登记
(宁可退化为改前行为,也不冒悬空风险)。
语义不变:规则 5.5 的证据链仍是 ① 结构体表按名(跨文件/跨遍)→ ② 正在定义类所属
模块 + find_struct_by_module → ③ 本文件已声明类归属表(自引用字段窗口 —— 登记与
查询在同一文件同一遍内,正是该表的作用域)。
2026-09-29 19:14:10 +08:00
..
2026-09-29 19:14:10 +08:00
2026-09-28 18:43:59 +08:00
2026-09-23 16:09:32 +08:00
2026-09-29 15:10:33 +08:00
2026-09-23 16:09:32 +08:00