Repository navigation
fix a use-after-free in the static_thread_pool remote-task hand-off - #2603
Merged
Merged
Conversation
`move_pending_to_local` pushes a worker's pending tasks into its BWoS queue and then spliced them out of the pending queue, which writes to the `next_` pointer of the last task pushed. Since NVIDIA#2552, the range `push_back` grants its last block to the thieves as soon as that block is full, so by then a thief may have stolen, run, and destroyed that task. TSan reported the data race (it made the counting-scope test "spawn lots of concurrent join-senders looking for UB" flaky), and when the memory had been reused for a new task, the write cleared that task's link in a remote queue, which lost tasks and hung the pool. Drop the pushed tasks from the pending queue without touching them, and note in `lifo_queue::push_back(first, last)` that thieves can steal the pushed items before it returns. The new test fails every time under TSan without the fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
the gcc 15 tsan job on #2602 failed with a data race between a thief's
operator deleteof a stolen task and the owning worker's__intrusive_queue::spliceinmove_pending_to_local.since #2552,
bwos::lifo_queue::push_back(first, last)grants its last block to the thieves as soon as that block is full.move_pending_to_localthen spliced the pushed tasks out of the pending queue, which writes to thenext_pointer of the last one after a thief could already have stolen, run, and destroyed it. besides the tsan report, the write could land on a new task that reused the memory and cut a remote queue short, which lost tasks and hung the pool. this drops the pushed tasks from the pending queue without touching them.the new test spawns 20k tiny tasks from outside a pool with one-task blocks. under tsan it fails every time without the fix and passes with it.
🤖 Generated with Claude Code