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
1 file changed