From 1b5246f29f417166edb6f197323da078f545b0dd Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Wed, 19 Aug 2026 21:14:20 +0800 Subject: [PATCH] =?UTF-8?q?fix(phase2):=20llc=20=E5=B9=B6=E8=A1=8C?= =?UTF-8?q?=E7=BA=BF=E7=A8=8B=E6=95=B0=E7=BB=84=E6=94=B9=E7=94=A8=20list[T?= =?UTF-8?q?hread]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit c.Deref 对 i8* 无法推断加载类型时只读 1 字节(旧编译器),th_ptrs 存 Thread* 后 join/is_alive 拿到垃圾句柄立即失败——llc 并行"5 秒误报失败" 的直接原因(ClassArrayTest 2 模块并发必现)。改 list[Thread] 保类型, get 返回明确类型,不再依赖 Deref 推断。含 [LLC-DBG] 插桩,验证后移除。 --- App/lib/core/BuildPipeline.vp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/App/lib/core/BuildPipeline.vp b/App/lib/core/BuildPipeline.vp index a1e0d1e..daa8cab 100644 --- a/App/lib/core/BuildPipeline.vp +++ b/App/lib/core/BuildPipeline.vp @@ -596,9 +596,11 @@ def run_llc_parallel(tasks: bytes, task_count: int, max_threads: int) -> int: return 0 if max_threads <= 0: max_threads = 1 - # Thread 对象指针数组(stdlib,保证线程对象存活到 join) - th_ptrs: bytes = stdlib.malloc(t.CSizeT(max_threads) * 8) - if th_ptrs is None: + # Thread 对象数组(list 保类型):c.Deref 对 i8* 无法推断加载类型时 + # 只读 1 字节 → 垃圾指针 → join/is_alive 立即失败(ClassArrayTest llc + # "5 秒误报失败"根因);list[Thread].get 返回类型明确,无推断问题。 + th_list: list[vthreading.Thread] | t.CPtr = list[vthreading.Thread](_mbuddy, max_threads) + if th_list is None: VLogger.error("run_llc_parallel: 线程数组分配失败", "PhaseB") return 1 slot_size: t.CSizeT = LlcTask.__sizeof__() @@ -615,14 +617,12 @@ def run_llc_parallel(tasks: bytes, task_count: int, max_threads: int) -> int: t.CUInt64T(tasks) + t.CSizeT(batch_start + j) * slot_size, t.CPtr)) th: vthreading.Thread | t.CPtr = vthreading.Thread(_llc_task_worker, t.CPtr(tsk)) th.start() - # u64 槽存 Thread*(转 u64 存储,读取时再转回指针) - c.DerefAs(t.CUInt64T(t.CUInt64T(th_ptrs) + t.CSizeT(j) * 8, t.CPtr), t.CUInt64T(th)) + th_list.set(j, th) j += 1 # 本批 join j = 0 while j < batch_n: - th_j: vthreading.Thread | t.CPtr = (vthreading.Thread | t.CPtr)(t.CPtr(c.Deref( - t.CUInt64T(t.CUInt64T(th_ptrs) + t.CSizeT(j) * 8, t.CPtr)))) + th_j: vthreading.Thread | t.CPtr = th_list.get(j) #region debug-point LLC7 stdio.printf("[LLC-DBG] join 前 %d\n", j) #endregion @@ -651,7 +651,6 @@ def run_llc_parallel(tasks: bytes, task_count: int, max_threads: int) -> int: ret = 1 j += 1 batch_start += batch_n - stdlib.free(th_ptrs) return ret