From b6f99a59a3270baf6bfd8e3152e58f1c47455d08 Mon Sep 17 00:00:00 2001 From: Justus Klausecker Date: Sat, 21 Mar 2026 01:11:26 +0100 Subject: [PATCH] std.Progress: use `cmpxchgStrong` instead of `cmpxchgWeak` for locking/unlocking IPC The `cmpxchgWeak` in `setIpcFile` could lead to the IPC file not being set even though there's still a slot available because one or more slots were spuriously skipped. The `cmpxcheWeak` in `serialize` could lead to an unused IPC slot not being locked and used even though it could be. --- lib/std/Progress.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/std/Progress.zig b/lib/std/Progress.zig index aa9c9f54beb1930ffad0424ed6a4738c0a7caaca..64afcaaf17555794228bb3603859794a09ddfba8 100644 --- a/lib/std/Progress.zig +++ b/lib/std/Progress.zig @@ -450,7 +450,7 @@ pub const Node = struct { const ipc = @atomicLoad(Ipc, ipc_ptr, .monotonic); if (ipc.locked or ipc.valid) continue; const generation = ipc.generation +% 1; - if (@cmpxchgWeak( + if (@cmpxchgStrong( Ipc, ipc_ptr, ipc, @@ -1133,7 +1133,7 @@ fn serialize(io: Io, serialized_buffer: *Serialized.Buffer) !Serialized { const ipc_data = &serialized_buffer.ipc_data[ipc_index.slot]; state: switch (ipc_data.state) { .unused => { - if (@cmpxchgWeak( + if (@cmpxchgStrong( Ipc, ipc, .{ .locked = false, .valid = true, .generation = ipc_index.generation }, -- 2.54.0