| Summary: | QFileDialog integration causes crashes on program exit | ||
|---|---|---|---|
| Product: | [Frameworks and Libraries] frameworks-kio | Reporter: | David Korth <gerbilsoft> |
| Component: | general | Assignee: | David Faure <faure> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | kdelibs-bugs-null, mpyne, nate |
| Priority: | NOR | ||
| Version First Reported In: | 5.29.0 | ||
| Target Milestone: | --- | ||
| Platform: | Gentoo Packages | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
Despite the very good instructions to reproduce, I'm not able to reproduce the crash myself. What version of Qt do you have? There have been changes to Qt to prevent dynamic libraries from being unloaded (in QFactoryLoader, QPluginLoader already refused to unload), which might explain your crash if you have an older Qt library. The initial patch to stop unloading of unneeded dynamic libraries was for Qt 5.8 (https://codereview.qt-project.org/#/c/140750/) but was later backported to Qt 5.6 and 5.7 (https://codereview.qt-project.org/#/c/174911/). But I'm not sure which releases contained the fix. If this stops the crash then it may be a similar issue to QStringLiteral crashers, where a cache was holding onto a pointer to data held by a shared dynamic library which was later unloaded as part of the shutdown process, but before the cache itself tried to do its own shutdown cleanup. I'm using Qt 5.7.1. I don't remember if this problem happened with 5.7.0. (On Windows, I'm using Qt 5.5.1, and it doesn't crash when using native dialogs.) I'll go through the 5.7.1 changelog again and see if there's anything relevant. Works for me in KDE Frameworks 5.49 and Qt 5.9.5 or 5.11.1. Let's call this fixed, and re-open if it it's reproducible with newer versions. Thanks! |
In a pure Qt application, if a QFileDialog is used to open a file, the program will crash when it exits. If the user cancels the QFileDialog, the crash won't happen. Test case: #include <QApplication> #include <QFileDialog> int main(int argc, char *argv[]) { QApplication app(argc, argv); QString filename = QFileDialog::getOpenFileName(nullptr, "Select File"); printf("file == %s\n", filename.toUtf8().constData()); } Compile with: gcc getOpenFileName-test.cpp -O getOpenFileName-test -fpic -fPIC -I /usr/include/qt5/QtWidgets -I /usr/include/qt5 -lQt5Widgets -lQt5Gui -lQt5Core GDB backtrace: Thread 1 "getOpenFileName" received signal SIGSEGV, Segmentation fault. 0x00007ffff6fe9bc4 in QHash<QRegExpEngineKey, QCache<QRegExpEngineKey, QRegExpEngine>::Node>::deleteNode2(QHashData::Node*) () from /usr/lib64/libQt5Core.so.5 (gdb) bt #0 0x00007ffff6fe9bc4 in QHash<QRegExpEngineKey, QCache<QRegExpEngineKey, QRegExpEngine>::Node>::deleteNode2(QHashData::Node*) () from /usr/lib64/libQt5Core.so.5 #1 0x00007ffff70ae7a9 in QHashData::free_helper(void (*)(QHashData::Node*)) () from /usr/lib64/libQt5Core.so.5 #2 0x00007ffff6ff466c in (anonymous namespace)::Q_QGS_globalEngineCache::innerFunction()::Holder::~Holder() () from /usr/lib64/libQt5Core.so.5 #3 0x00007ffff62c2a80 in __run_exit_handlers (status=0, listp=0x7ffff66235b8 <__exit_funcs>, run_list_atexit=run_list_atexit@entry=true, run_dtors=run_dtors@entry=true) at exit.c:83 #4 0x00007ffff62c2ada in __GI_exit (status=<optimized out>) at exit.c:105 #5 0x00007ffff62ad2a8 in __libc_start_main (main=0x400be6 <main>, argc=1, argv=0x7fffffffd988, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffd978) at ../csu/libc-start.c:323 #6 0x0000000000400b1a in _start () This crash does not occur if QFileDialog::DontUseNativeDialog is set. My system has KDE Frameworks 5.29 and KDE Applications 16.12.0.