OSDN Git Service

Fix sampling profiler race condition
authorMathieu Chartier <mathieuc@google.com>
Wed, 11 Mar 2015 16:54:22 +0000 (09:54 -0700)
committerMathieu Chartier <mathieuc@google.com>
Wed, 11 Mar 2015 17:38:26 +0000 (10:38 -0700)
commit02e5f160d9cc02da20d9e47af30f948c462f7043
tree3a9ab3cc6e1e9226ef1c5818f16db873e28c3ec6
parent4fe8c2a9110916386e5fe8428410cd5795f57036
Fix sampling profiler race condition

Thread 1 is running RunSamplingThread and has just read trace into
the_trace.

Thread 2 is calling Trace::Stop and has just suspended all the
threads. At this point thread 1 is blocked on the SuspendAll.
Thread 2 goes and deletes the trace which Thread 1 still has a
pointer to, calls ResumeAll(). At this point thread 1 suspends the
threads and adds samples to the just deleted trace.

The fix is to join the thread before we delete the trace.

Bug: 18950006
Change-Id: I3090c4dac392a4e5d880c4dc8d9385aef53c7425
runtime/trace.cc