[Development] Using platform-native APIs for terminating QThreads

Thiago Macieira thiago.macieira at intel.com
Fri Sep 2 22:35:59 CEST 2016


Em sexta-feira, 2 de setembro de 2016, às 18:06:27 CEST, Giuseppe D'Angelo 
escreveu:
> Il 02/09/2016 17:21, Thiago Macieira ha scritto:
> > Our question is: do we want to rely on abi::__forced_unwind? It's declared
> > if we include the public header <cxxabi.h>, but it's not documented in
> > the ABI spec: https://mentorembedded.github.io/cxx-abi/abi-eh.html
> 
> This one in particular is also documented/mentioned in libstdc++'s manual:
> 
> https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_exceptions.html
> 
> Wonder if it's a good idea to rely on this, though (what about libc++ or
> other STD implementations?)

There's no "__forced_unwind" in either LLVM libc++ (libcxx.git), libc++abi 
(libcxxabi) or libunwind. libstdc++ (libsupc++) has it in 
__gxx_personality_v0, which libc++abi also provides, but doesn't reference 
that class.

That means users of std::thread (from either libc++ or libstdc++) when using 
libc++abi will not catch the exception at all and the application will just 
crash/quit when a cancellation happens with glibc pthread. I'd say that's a 
defect in libc++ and in libc++abi caused by the way glibc does pthread 
cancellation.

However, the documentation from the ABI says that forced unwinds cannot be 
stopped, so you can't swallow the exception even if you wanted to. Are you 
sure that the application crashes when you pthread_exit() when 
QThreadPrivate::start() is noexcept?

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center




More information about the Development mailing list