[Development] Using platform-native APIs for terminating QThreads
giuseppe.dangelo at kdab.com
Fri Sep 2 12:32:48 CEST 2016
I'm trying to introduce a change  which will make QThread invoke
std::terminate in case an exception is thrown from the new thread
(including, but not limited to: user's reimplementation of QThread::run;
slots listening to the QThread::started / finished signals; custom event
The idea is to align ourselves to what std::thread does.
There's a small catch, however: user code might be using platform-native
APIs such as pthread_exit(3) in order to make a QThread quit.
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 (!).
The question for the ML is: is this a scenario Qt has ever officially
supported, and a scenario that we should support in the future?
(QThread documentation does not talk about how QThread itself is
implemented, so actually relying on the that it has pthread semantics is
already a slight API abuse by the users).
Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Senior Software Engineer
KDAB (UK) Ltd., a KDAB Group company | Tel: UK +44-1625-809908
KDAB - The Qt Experts
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 4007 bytes
Desc: Firma crittografica S/MIME
More information about the Development