Commit 611639da authored by nhiroki's avatar nhiroki Committed by Commit bot

Worker: Stop disposing of the global scope scheduler in WorkerThread::WillProcessTask()

When forcible termination is requested, WorkerThread::WillProcessTask() calls
PrepareForShutdownOnWorkerThread() that disposes of the global scope scheduler,
which in turn disposes of the task to be run. This results in crashes.

This CL moves PrepareForShutdownOnWorkerThread() call from WillProcessTask() to
DidProcessTask() to fix the crashes. This could still cause a crash if the
termination request is issued between DidProcessTask() and WillProcessTask()
because in the case a task runs and may access an empty handle returned by V8
API. However, such a case would be rare because generally forcible termination
is scheduled as a delayed task(*) and DidProcessTask() can have a chance to
check IsForciblyTerminated() before it's fired.

(*) Forcible termination could synchronously be called in some path, but it'll
be removed (see issue 641846).

BUG=713914

Review-Url: https://codereview.chromium.org/2849583004
Cr-Commit-Position: refs/heads/master@{#468001}
parent f305a94d
......@@ -174,12 +174,6 @@ void WorkerThread::WillProcessTask() {
// No tasks should get executed after we have closed.
DCHECK(!GlobalScope()->IsClosing());
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();
}
}
void WorkerThread::DidProcessTask() {
......@@ -192,6 +186,10 @@ void WorkerThread::DidProcessTask() {
// Stop further worker tasks to run after this point.
PrepareForShutdownOnWorkerThread();
} else 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();
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment