[SurfaceFlinger] Fix crash in SurfaceTracing
mThread is guarded by a lock, so acquire the lock to steal the thread
when tracing finishes.
Bug: 147319235
Test: winscope
Change-Id: Id0e103c66c8937272aa9a1c02f153eea2e2f9859
diff --git a/services/surfaceflinger/SurfaceTracing.cpp b/services/surfaceflinger/SurfaceTracing.cpp
index 20c8d7a..a9c3332 100644
--- a/services/surfaceflinger/SurfaceTracing.cpp
+++ b/services/surfaceflinger/SurfaceTracing.cpp
@@ -129,7 +129,12 @@
}
status_t SurfaceTracing::writeToFile() {
- mThread.join();
+ std::thread thread;
+ {
+ std::scoped_lock lock(mTraceLock);
+ thread = std::move(mThread);
+ }
+ thread.join();
return mLastErr;
}