authorgravatar for justus@klausecker.deJustus Klausecker <justus@klausecker.de> 2026-03-21 01:11:26+01:00
committergravatar for justus@klausecker.deJustus Klausecker <justus@klausecker.de> 2026-03-21 03:00:50+01:00
logb6f99a59a3270baf6bfd8e3152e58f1c47455d08
tree34becf7fc3f126947da0ab54c8987df4f2b3ffb6
parente938344100da959308aa27dee1295e5ce02efc30

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.

1 files changed, 2 insertions(+), 2 deletions(-)

lib/std/Progress.zig+2-2
......@@ -450,7 +450,7 @@ pub const Node = struct {
450450 const ipc = @atomicLoad(Ipc, ipc_ptr, .monotonic);
451451 if (ipc.locked or ipc.valid) continue;
452452 const generation = ipc.generation +% 1;
453 if (@cmpxchgWeak(
453 if (@cmpxchgStrong(
454454 Ipc,
455455 ipc_ptr,
456456 ipc,
......@@ -1133,7 +1133,7 @@ fn serialize(io: Io, serialized_buffer: *Serialized.Buffer) !Serialized {
11331133 const ipc_data = &serialized_buffer.ipc_data[ipc_index.slot];
11341134 state: switch (ipc_data.state) {
11351135 .unused => {
1136 if (@cmpxchgWeak(
1136 if (@cmpxchgStrong(
11371137 Ipc,
11381138 ipc,
11391139 .{ .locked = false, .valid = true, .generation = ipc_index.generation },