From 1226bb9268f20740a69afd3097d40b4d3e371647 Mon Sep 17 00:00:00 2001 From: Brandon Black Date: Mon, 30 Mar 2026 07:01:40 -0500 Subject: [PATCH] LinuxThreadImpl: be precise in tls.prepareArea arg This isn't causing any functional problem today, but technically `mapped[tls_offset..]` runs past the tls part of `mapped` and into the `Instance` storage, and currently `prepareArea()` memsets its entire argument to zero. It is only the current layout and initialization order of `mapped` that prevents this from being a problem. Being more precise here avoids future footguns if any of that changes. --- lib/std/Thread.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/std/Thread.zig b/lib/std/Thread.zig index 6be9f06f779bd88664e1b2a55e54c5a90dc06932..8f31add6e20892c48bf1872fc6829ca55a4bd357 100644 --- a/lib/std/Thread.zig +++ b/lib/std/Thread.zig @@ -1489,7 +1489,7 @@ const LinuxThreadImpl = struct { } // Prepare the TLS segment and prepare a user_desc struct when needed on x86 - var tls_ptr = linux.tls.prepareArea(mapped[tls_offset..]); + var tls_ptr = linux.tls.prepareArea(mapped[tls_offset..][0..linux.tls.area_desc.size]); var user_desc: if (target.cpu.arch == .x86) linux.user_desc else void = undefined; if (target.cpu.arch == .x86) { defer tls_ptr = @intFromPtr(&user_desc); -- 2.54.0