Check whether the worker was terminated before accessing its backing thread
This patch fixes a race condition in WorkerThread initialization which
can lead to a null pointer dereference. An example triggering sequence
of events is:
Main thread Worker thread
----------- -------------
1. ServiceWorkerThread::start
| postTask
'----------------------------------------.
|
V
2. ~ServiceWorkerThread 3. ServiceWorkerThread::initialize
=> ~WebThreadSupportingGC => derefs backingThread().platformThread()
=> backingThread().platformThread() => segfault
becomes null.
In other words, the worker thread is terminated before it has a chance
to run the posted WorkerThread::initialize() function.
The fix is to check whether the thread was terminated before assuming
the backing thread is still valid.
BUG=492592
Review URL: https://codereview.chromium.org/
1149833011
git-svn-id: svn://svn.chromium.org/blink/trunk@196058 bbb929c8-8fbe-4397-9dbb-9b2b20218538