Fix sequence_manager_fuzzer race
In the Edge fuzzer runs, we're seeing crashes in sequence_manager_fuzzer via ThreadManager::PostDelayedTask. The root cause appears to be the fact that a cross-thread post can execute on one thread while the thread where the target ThreadManager lives is executing a shutdown task. The TestTaskQueue pointer that is held by ThreadManager::PostDelayedTask can be deleted when the TaskQueueWithVoters is erased from the task_queues_ vector. Keeping a scoped_refptr on the stack allows safe use of the TestTaskQueue pointer for the duration of the function, and the task runner infrastructure gracefully handles posting to a TaskQueue that has gone away. That change alone fixes the fuzzer crash, but there's still a race - since only GetTaskQueueFor is protected by the lock (same lock is acquired before erasing the vector entry), it's possible for the TaskQueueWithVoters to be destroyed along with its queue before we take the extra reference when assigning the stack scoped_refptr. To fix this, I've converted TaskQueueWithVoters to a thread-safe refcounted type and GetTaskQueueFor now returns a scoped_refptr<TaskQueueWithVoters> instead of a raw pointer. Bug: 977527 Change-Id: I9f49531bd7d8c76bae36a65ed150c32714039d45 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1835216Reviewed-by:Alex Clarke <alexclarke@chromium.org> Commit-Queue: Daniel Libby <dlibby@microsoft.com> Cr-Commit-Position: refs/heads/master@{#703781}
Showing
Please register or sign in to comment