diff --git a/libs/utils/Threads.cpp b/libs/utils/Threads.cpp index ad9a94f594f58..00d009b14a0d6 100644 --- a/libs/utils/Threads.cpp +++ b/libs/utils/Threads.cpp @@ -799,6 +799,9 @@ void Thread::requestExit() status_t Thread::requestExitAndWait() { + // hold a reference so mThreadExitedCondition is not destroyed before wait() returns + sp strong(mHoldSelf); + if (mThread == getThreadId()) { LOGW( "Thread (this=%p): don't call waitForExit() from this "