From 6759406a7efa60900c143dd5216137c147664f2c Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Sat, 15 Aug 2026 06:36:53 +0800 Subject: [PATCH] =?UTF-8?q?fix(=5Fwithcontent):=20=5Finit=5Ftls=20?= =?UTF-8?q?=E5=8A=A0=20=5Ftls=5Findex=3D=3D0=20=E5=AE=88=E5=8D=AB=EF=BC=88?= =?UTF-8?q?TPV=20=E6=9C=AA=E5=AE=9E=E7=8E=B0=20@t.TLS=20=E4=B8=80=E6=AC=A1?= =?UTF-8?q?=E6=80=A7=E8=AF=AD=E4=B9=89=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TPV 编译器没有 @t.TLS 的首次执行守卫(TPC 有:全局标志+跳过块), _init_tls 每次调用都重新 TlsAlloc → _get_stack 每次拿到新 TLS 索引和 新空栈 → push/find 各用各的栈,provider 永远匹配失败(Test 9 注入仍 FAIL 的根因)。_tls_index 初始为 0(TlsAlloc 成功不会返回 0),判重即 等价 TLS 语义。待办:TPV 函数翻译对齐 TPC HandlesFunctions.py L1763 实现 @t.TLS。 --- includes/_withcontent.vp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/includes/_withcontent.vp b/includes/_withcontent.vp index 01c82e4..6036313 100644 --- a/includes/_withcontent.vp +++ b/includes/_withcontent.vp @@ -26,7 +26,12 @@ _tls_index: ULONG = 0 def _init_tls(): """Initialize TLS index (executes once; subsequent calls are skipped).""" global _tls_index - _tls_index = TlsAlloc() + # TPV 未实现 @t.TLS 的"首次执行"守卫(函数每次调用都执行体), + # 不加守卫会导致每次 _get_stack 都 TlsAlloc 新索引 → 每次拿到新 + # 空栈 → push/find 各用各的栈,provider 永远匹配失败。_tls_index + # 初始为 0(TlsAlloc 成功不会返回 0),以此判重即等价 TLS 语义。 + if _tls_index == 0: + _tls_index = TlsAlloc() def _get_stack() -> _ProviderStack | t.CPtr: