Rethrow abi::__forced_unwind in wxThread code under Unix.

We must always rethrow the special abi::__forced_unwind exception when
handling exception in threads under Linux as the NPTL simply terminates the
process at first opportunity if this exception is not rethrown.

See http://udrepper.livejournal.com/21541.html for more details.

Closes #14626.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72531 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2012-09-20 23:00:44 +00:00
parent 9b9a7c3331
commit e02ea2030c
4 changed files with 84 additions and 33 deletions

View File

@@ -54,6 +54,10 @@
#include <thread.h>
#endif
#ifdef HAVE_CXXABI_H
#include <cxxabi.h>
#endif
// we use wxFFile under Linux in GetCPUCount()
#ifdef __LINUX__
#include "wx/ffile.h"
@@ -857,6 +861,18 @@ void *wxThreadInternal::PthreadStart(wxThread *thread)
wxT("Thread %p Entry() returned %lu."),
THR_ID(pthread), wxPtrToUInt(pthread->m_exitcode));
}
#ifdef HAVE_CXXABI_H
// When using common C++ ABI under Linux we must always rethrow this
// special exception used to unwind the stack when the thread was
// cancelled, otherwise the thread library would simply terminate the
// program, see http://udrepper.livejournal.com/21541.html
catch ( abi::__forced_unwind& )
{
wxCriticalSectionLocker lock(thread->m_critsect);
pthread->SetState(STATE_EXITED);
throw;
}
#endif // HAVE_CXXABI_H
wxCATCH_ALL( wxTheApp->OnUnhandledException(); )
{