| author | |
| committer | |
| log | fd74c5742d3c8343868516c03a6a0695280744d1 |
| tree | 0988ebfa90fe3da65d12be7d682a7dc797c925a8 |
| parent | dbfe34167de6b2a3a46ee4aff8f016c5afda7ccf |
On FreeBSD, the maximum waiters should be Cs INT_MAX instead of the maximum of a u32. Waiting for the Io.Event in the broadcast test triggers this bug.
Resolves #30715
Co-authored-by: Simon Galli <hubi@hubidubi.net>
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30094
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
Co-authored-by: hubidubi <hubidubi@noreply.codeberg.org>
Co-committed-by: hubidubi <hubidubi@noreply.codeberg.org>2 files changed, 7 insertions(+), 6 deletions(-)
lib/std/Io/Threaded.zig+1-1| ... | ... | @@ -1104,7 +1104,7 @@ const Thread = struct { |
| 1104 | 1104 | const rc = std.c._umtx_op( |
| 1105 | 1105 | @intFromPtr(ptr), |
| 1106 | 1106 | @intFromEnum(std.c.UMTX_OP.WAKE_PRIVATE), |
| 1107 | @as(c_ulong, max_waiters), | |
| 1107 | @as(c_ulong, @min(max_waiters, std.math.maxInt(c_int))), | |
| 1108 | 1108 | 0, // there is no timeout struct |
| 1109 | 1109 | 0, // there is no timeout struct pointer |
| 1110 | 1110 | ); |
lib/std/Io/test.zig+6-5| ... | ... | @@ -818,10 +818,11 @@ test "Event broadcast" { |
| 818 | 818 | event: Io.Event = .unset, |
| 819 | 819 | counter: std.atomic.Value(usize) = std.atomic.Value(usize).init(num_threads), |
| 820 | 820 | |
| 821 | fn wait(self: *@This()) void { | |
| 821 | fn wait(self: *@This()) !void { | |
| 822 | 822 | if (self.counter.fetchSub(1, .acq_rel) == 1) { |
| 823 | 823 | self.event.set(io); |
| 824 | 824 | } |
| 825 | try self.event.wait(io); | |
| 825 | 826 | } |
| 826 | 827 | }; |
| 827 | 828 | |
| ... | ... | @@ -829,9 +830,9 @@ test "Event broadcast" { |
| 829 | 830 | start_barrier: Barrier = .{}, |
| 830 | 831 | finish_barrier: Barrier = .{}, |
| 831 | 832 | |
| 832 | fn run(self: *@This()) void { | |
| 833 | self.start_barrier.wait(); | |
| 834 | self.finish_barrier.wait(); | |
| 833 | fn run(self: *@This()) !void { | |
| 834 | try self.start_barrier.wait(); | |
| 835 | try self.finish_barrier.wait(); | |
| 835 | 836 | } |
| 836 | 837 | }; |
| 837 | 838 | |
| ... | ... | @@ -841,5 +842,5 @@ test "Event broadcast" { |
| 841 | 842 | for (&threads) |*t| t.* = try std.Thread.spawn(.{}, Context.run, .{&ctx}); |
| 842 | 843 | defer for (threads) |t| t.join(); |
| 843 | 844 | |
| 844 | ctx.run(); | |
| 845 | try ctx.run(); | |
| 845 | 846 | } |