DescriptionFix a race condition during worker thread initialization
This patch fixes a race condition which can result in a worker thread
accessing freed memory during its initialization. One possible sequence
of events is:
1. The main thread creates the worker thread and posts a task to run
WorkerThread::initialize().
2. Immediately after this, the main thread calls
WorkerThread::terminateAndWait() to shut down the worker thread.
3. WorkerThread::terminateAndWait() notices that the worker hasn't
initialized yet and signals m_terminationEvent.
4. The caller of terminateAndWait() assumes that the WorkerThread has
been terminated and deallocates either the WorkerThread itself or
some object that it depends on.
5. Finally, WorkerThread::initialize starts to run on the worker thread,
accessing memory freed in step #4.
The fix is to always signal m_terminationEvent from the worker thread to
guarantee that we don't think the thread terminated before it actually
did.
BUG=499153
Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=197196
Patch Set 1 #Patch Set 2 : Add a test. #Patch Set 3 : Fixed the test. #
Total comments: 2
Patch Set 4 : AnyNumber => AtMost #
Messages
Total messages: 14 (5 generated)
|
||||||||||||||||||||||||||||