From 6ff76f3cb623cec25c0d9ea7a8747cd2383ab8b1 Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Wed, 19 Aug 2026 22:49:37 +0800 Subject: [PATCH] =?UTF-8?q?fix(gentype):=20t.CPtr.=5F=5Fsizeof=5F=5F()=20?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=208=20=E4=BF=AE=E5=A4=8D=20list[CPtr]=20elem?= =?UTF-8?q?=5Fsize=3D0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CPtr 无显式 Size(t.py class CPtr 未设 Size)→ GetClassByName 路径 size_bits=0 → t.CPtr.__sizeof__() 返回 0 → list[t.CPtr](_mbuddy) 单参 构造时 elem_size=0(T.__sizeof__() 分支)→ append 崩溃(ASAN: 读 0xf8 零页,pool.alloc 处)。GetClassByName 路径补 POINTER 判断:HasPosition (POINTER) 且 size_bytes==0 → 8(指针大小,与 str/bytes 一致)。 --- lib/core/Handles/HandlesExprCall.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/core/Handles/HandlesExprCall.py b/lib/core/Handles/HandlesExprCall.py index 9883e58..69e510d 100644 --- a/lib/core/Handles/HandlesExprCall.py +++ b/lib/core/Handles/HandlesExprCall.py @@ -3654,6 +3654,13 @@ class ExprCallHandle(BaseHandle): ctype_inst = ctype_cls() size_bits = getattr(ctype_inst, 'Size', 0) or 0 size_bytes = size_bits // 8 + # POINTER 类型(CPtr 等)Size 为 None/0 → 指针大小 8。 + # 根因:t.CPtr.__sizeof__() 返回 0 → list[t.CPtr] + # elem_size=0 → append 全写同槽/alloc(0) → 崩溃。 + if getattr(ctype_inst, 'HasPosition', None) \ + and ctype_inst.HasPosition(CType.POINTER) \ + and size_bytes == 0: + size_bytes = 8 return ir.Constant(ir.IntType(64), size_bytes) except Exception as _e: if _config_mode == "strict":