[Development] Using platform-native APIs for terminating QThreads

Thiago Macieira thiago.macieira at intel.com
Fri Sep 2 17:21:44 CEST 2016


Em sexta-feira, 2 de setembro de 2016, às 13:35:12 CEST, Marc Mutz escreveu:
> On Friday 02 September 2016 12:32:48 Giuseppe D'Angelo wrote:
> > On some implementations (notably: glibc), pthread_exit is implemented by
> > throwing an exception, because it needs to run the pushed cleanup
> > handlers. The net result is that, with my change applied, pthread_exit
> > won't make the thread exit but crash the application instead (!).
> 
> I thought you can catch that particular exception type, and ignore it (=
> rethrow). It's something with cxa and abi, but I can't find it anymore.

I've found the libstdc++ code for std::thread. It does this:

      __try
        {
          __t->_M_run();
        }
      __catch(const __cxxabiv1::__forced_unwind&)
        {
          __throw_exception_again;
        }
      __catch(...)
        {
          std::terminate();
        }

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

Should we ask the ABI people?

Or are we ok with what Peppe proposed: if you pthread_exit() a QThread, the 
whole application exits.

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




More information about the Development mailing list