X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9a83f860948059b0273b5cc6d9e43fadad3ebfca..28756ab9c52aba43c99409cea3a9faedb1bccf6a:/src/unix/threadpsx.cpp diff --git a/src/unix/threadpsx.cpp b/src/unix/threadpsx.cpp index 9c1afb98de..142268d1b0 100644 --- a/src/unix/threadpsx.cpp +++ b/src/unix/threadpsx.cpp @@ -725,7 +725,7 @@ public: void SetState(wxThreadState state) { #if wxUSE_LOG_TRACE - static const wxChar *stateNames[] = + static const wxChar *const stateNames[] = { wxT("NEW"), wxT("RUNNING"), @@ -1778,14 +1778,15 @@ static void ScheduleThreadForDeletion() static void DeleteThread(wxThread *This) { - // gs_mutexDeleteThread should be unlocked before signalling the condition - // or wxThreadModule::OnExit() would deadlock - wxMutexLocker locker( *gs_mutexDeleteThread ); - wxLogTrace(TRACE_THREADS, wxT("Thread %p auto deletes."), This->GetId()); delete This; + // only lock gs_mutexDeleteThread after deleting the thread to avoid + // calling out into user code with it locked as this may result in + // deadlocks if the thread dtor deletes another thread (see #11501) + wxMutexLocker locker( *gs_mutexDeleteThread ); + wxCHECK_RET( gs_nThreadsBeingDeleted > 0, wxT("no threads scheduled for deletion, yet we delete one?") );