Skip to content

Commit 6afcde9

Browse files
committed
Revert "Fix potential ThreadPool UAF (#113)"
This reverts commit dbe2291, reversing changes made to 43c7e4b.
1 parent d46619a commit 6afcde9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/ThreadPool.zig

+6-2
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,12 @@ fn unregister(noalias self: *ThreadPool, noalias maybe_thread: ?*Thread) void {
335335

336336
fn join(self: *ThreadPool) void {
337337
// Wait for the thread pool to be shutdown() then for all threads to enter a joinable state
338-
self.join_event.wait();
339-
const sync: Sync = @bitCast(self.sync.load(.monotonic));
338+
var sync: Sync = @bitCast(self.sync.load(.monotonic));
339+
if (!(sync.state == .shutdown and sync.spawned == 0)) {
340+
self.join_event.wait();
341+
sync = @bitCast(self.sync.load(.monotonic));
342+
}
343+
340344
assert(sync.state == .shutdown);
341345
assert(sync.spawned == 0);
342346

0 commit comments

Comments
 (0)