Threads in QApplication Issue with on Linux cross-compiled Qt v6.9.1
-
The Issue
Context
I've been building a docker image for my C++ Qt project which allows me to build the same Qt app for Linux x86_64, aarch64 and Windows x86_64. The image contains Wine to perform the same unittests for Windows as for the Linux build. The image is available from Docker Hub for v6.8.1 and for v6.9.1. The image contains 3 times the Qt framework for the different platforms.
Thread Problem on Closing the QApplication
What I found is that only the Windows build has one ore more threads hanging or being blocked from terminating making the application not exit. The following simple application just will not exit when the application is build using the Linux MinGW cross compiler on Ubuntu 24.04 which seems to be version 13.0.0.
#include <QApplication> #include <QDebug> #include <QPushButton> int main(int argc, char* argv[]) { int rv{0}; QApplication app(argc, argv); QWidget* wgt = new QPushButton(QString(qVersion()) + "/" + QT_VERSION_STR); wgt->setWindowTitle("Qt Test Application"); wgt->resize(300, 120); wgt->show(); rv = app.exec(); delete wgt; qDebug() << "Exiting with code:" << rv; return rv; }The problem threads are part of the by QApplication created pool of threads.
Running the application on Windows or Linux using Wine has the same effect.
When building the Qt framework from Windows using the MinGW version 13.2.0 does not cause the problem.QtCore Significant Changes v6.8 and v6.9
On GitHub I saw development when comparing v6.8.1...v6.9.1 on a thread "Quality Of Service Level" and in Windows only file src/corelib/thread/qthread_win.cpp.
Using Native Windows Build Framework (not possible)
When compiling the Qt frame work using MinGW (13.2.0) natively on Windows is not possible due to
bug 116159 in MinGW GCC.
It should be possible to use an older GCC compiler using a newer libstdc++-6.dll library having backwards compatibility.
That bug wil be resolved it seems in GCC version 13.4.Bad Workaround
So for now I call
std::exit(0)before theQApplicationinstance goes out of scope, only when compiling the Windows target, which is not a desirable solution. Another one is, canceling all threads except the main one which is also bad.QtBug Report
I created a bug report QTBUG-139361 but I doubt it will be fixed at all.
Question
Is there someone also building the Windows Qt framework v6.9.x from source on Linux using a cross-compiler?
If so do you have the same problem as described here when running my small application? -
So since it's a compiler bug - what should Qt do against it?