Commit 27c6465
committed
Fix TSan race in blocking_context::enqueue
enqueue was calling impl_->cv.notify_one() outside the lock
scope. A foreign thread could still be inside notify_one() when
the main thread drained the queue, completed the task, saw
signal_done, and destroyed the context. TSan flagged the read
against cv during cond_signal after the waiter had released it.
Move notify_one inside the lock_guard scope, matching signal_done.
The race was latent before run() was switched to post on the
return trip: no foreign thread ever called blocking_executor::post,
so enqueue only ran on the pumping thread. testHopsBackToIoThread
exercises a compute-pool worker posting back to blocking_executor
via the return trampoline, which is what revealed the race under
TSan.1 parent d5a0406 commit 27c6465
1 file changed
Lines changed: 2 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
| 90 | + | |
| 91 | + | |
94 | 92 | | |
95 | 93 | | |
96 | 94 | | |
| |||
0 commit comments