Skip to content

Commit

Permalink
Worker: Don't run micro tasks when V8 Isolate is terminated
Browse files Browse the repository at this point in the history
We should not run micro tasks when V8 Isolate is terminated because that causes
a crash.

This CL doesn't add tests because this is a timing issue and it's difficult to
reproduce it without complicating tests.

Bug: 775224
Change-Id: I1bb36050d4aa7fd6b9aefca1944eb63ee7e5f899
Reviewed-on: https://chromium-review.googlesource.com/734562
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Hiroki Nakagawa <nhiroki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#511319}
  • Loading branch information
nhiroki authored and Commit Bot committed Oct 25, 2017
1 parent 541b864 commit 145feda
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions third_party/WebKit/Source/core/workers/WorkerThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,19 +189,22 @@ void WorkerThread::WillProcessTask() {

void WorkerThread::DidProcessTask() {
DCHECK(IsCurrentThread());
Microtask::PerformCheckpoint(GetIsolate());
GlobalScope()->ScriptController()->GetRejectedPromises()->ProcessQueue();
if (GlobalScope()->IsClosing()) {
// This WorkerThread will eventually be requested to terminate.
GetWorkerReportingProxy().DidCloseWorkerGlobalScope();

// Stop further worker tasks to run after this point.
PrepareForShutdownOnWorkerThread();
} else if (IsForciblyTerminated()) {
return;
}
if (IsForciblyTerminated()) {
// The script has been terminated forcibly, which means we need to
// ask objects in the thread to stop working as soon as possible.
PrepareForShutdownOnWorkerThread();
return;
}
Microtask::PerformCheckpoint(GetIsolate());
GlobalScope()->ScriptController()->GetRejectedPromises()->ProcessQueue();
}

v8::Isolate* WorkerThread::GetIsolate() {
Expand Down

0 comments on commit 145feda

Please sign in to comment.