Worker: Fix a race condition on task runner handling
WebSharedWorkerImpl accesses WorkerScheduler from the main thread to take a task runner, and then dispatches a connect event to SharedWorkerGlobalScope using the task runner. This causes a race condition if close() is called on the global scope on the worker thread while the task runner is being taken on the main thread: close() call disposes of WorkerScheduler, and accessing the scheduler after that is not allowed. See the issue for details. To fix this, this CL makes WebSharedWorkerImpl capture the task runner between starting a worker thread (initializing WorkerScheduler) and posting a task to evaluate worker scripts that may call close(). This ensures that WebSharedWorkerImpl accesses WorkerScheduler before the scheduler is disposed of. Bug: 1104046 Change-Id: I145cd39f706019c33220fcb01ed81f76963ffff0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2308550 Commit-Queue: Hiroki Nakagawa <nhiroki@chromium.org> Reviewed-by:Kenichi Ishibashi <bashi@chromium.org> Cr-Commit-Position: refs/heads/master@{#790284}
Showing
Please register or sign in to comment