Skip to content

Commit 4bcafe8

Browse files
author
Stephen Gutekanst
committed
object: fix race detected by tsan in mpsc queue
Signed-off-by: Stephen Gutekanst <[email protected]>
1 parent 40dcef1 commit 4bcafe8

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/mpsc.zig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,15 @@ pub fn Queue(comptime Value: type) type {
350350
// Lost race (with another takeAll() or pop()), retry from start
351351
continue :outer;
352352
}
353+
354+
// Ensure all previous atomic operations (including linking) are complete
355+
// Specifically this part of pushRaw():
356+
//
357+
// // Link previous node to new node
358+
// @atomicStore(?*Node, &prev.next, node, .release);
359+
//
360+
_ = @atomicLoad(*Node, &q.head, .acquire);
361+
353362
return tail;
354363
}
355364
}

0 commit comments

Comments
 (0)