Skip to content

Commit

Permalink
Revert "Fix potential ThreadPool UAF (mitchellh#113)"
Browse files Browse the repository at this point in the history
This reverts commit dbe2291, reversing
changes made to 43c7e4b.
  • Loading branch information
mitchellh authored and steeve committed Jan 17, 2025
1 parent fc805c8 commit bfb464b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/ThreadPool.zig
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,12 @@ fn unregister(noalias self: *ThreadPool, noalias maybe_thread: ?*Thread) void {

fn join(self: *ThreadPool) void {
// Wait for the thread pool to be shutdown() then for all threads to enter a joinable state
self.join_event.wait();
const sync: Sync = @bitCast(self.sync.load(.monotonic));
var sync: Sync = @bitCast(self.sync.load(.monotonic));
if (!(sync.state == .shutdown and sync.spawned == 0)) {
self.join_event.wait();
sync = @bitCast(self.sync.load(.monotonic));
}

assert(sync.state == .shutdown);
assert(sync.spawned == 0);

Expand Down

0 comments on commit bfb464b

Please sign in to comment.