Details
-
Suggestion
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.9
-
None
-
357351b7a (dev), 60eaa42a2 (6.9), bfbd1a281 (dev), ea6d467c0 (6.9), 77ec9dc6d (6.8), c17da11f5 (6.8)
Description
Commit c3a2b9f35a9a12ff3c6f5f0d11844de161b47c2a added categorised logging to the QObject::deleterLater feature. Unfortunately, some of the categorised logging in question happen at very inopportune moments: very late in a thread's exit or in the application's exit. This was first noticed in QTBUG-129927.
I believe this is the worst offender:
d->threadState = QThreadPrivate::Finishing; locker.unlock(); emit thr->finished(QThread::QPrivateSignal()); qCDebug(lcDeleteLater) << "Sending deferred delete events as part of finishing thread" << thr; QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete);
For threads started with QThread, this function is run right after the user's code returns from QThread::run() (except for Qt 6.4-6.8, where it was run later on some platforms, but that was changed back to the historical time with the commit that fixed QTBUG-129927). For adopted threads, this function is runs late, when either PThread runs the pthread_key_t callbacks or the C++ runtime runs the non-trivial destructors.
Specifically, do note the thread that executed main() is an adopted thread.
One crash was noticed in tests/auto/widgets/kernel/qapplication/modal/base.cpp, which calls ::exit() from a QTimer. I believe I fixed that one in QThread itself. The one I can't fix because I can't reproduce is:
$ ctest --test-dir $objdir -R test_add_binary_resources_delayed_file --output-on-failure ... Running test command: "/Users/tjmaciei/obj/qt/qt6/qtbase/tests/auto/cmake/test_add_binary_resources_delayed_file/test_add_binary_resources_delayed_file" Test command failed: /Users/tjmaciei/obj/qt/qt6/qtbase/tests/auto/cmake/test_add_binary_resources_delayed_file/test_add_binary_resources_delayed_file [4223500.427] (9701 36767941)(unknown): ASSERT failure in Type &QtGlobalStatic::Impl<QtGlobalStatic::Holder<(anonymous namespace)::Q_QGS_defaultLocalePrivate, (anonymous namespace)::Q_QGS_defaultLocalePrivate>>::operator*() const [Holder = QtGlobalStatic::Holder<(anonymous namespace)::Q_QGS_defaultLocalePrivate, (anonymous namespace)::Q_QGS_defaultLocalePrivate>]: "The global static was used after being destroyed", file /Users/tjmaciei/src/qt/qt6/qtbase/src/corelib/global/qglobalstatic.h, line 136
Attachments
Gerrit Reviews
For Gerrit Dashboard: QTBUG-132429 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
613505,5 | Revert "Add categorized logging of delete later machinery" | dev | qt/qtbase | Status: MERGED | +2 | 0 |
613664,15 | tst_Q*Application: add tests for unusual qApp creations and exits | dev | qt/qtbase | Status: MERGED | +2 | 0 |
615203,2 | Revert "Add categorized logging of delete later machinery" | 6.9 | qt/qtbase | Status: MERGED | +2 | 0 |
615299,3 | Revert "Add categorized logging of delete later machinery" | 6.8 | qt/qtbase | Status: MERGED | +2 | 0 |
616454,2 | tst_Q*Application: add tests for unusual qApp creations and exits | 6.9 | qt/qtbase | Status: MERGED | +2 | 0 |
616460,4 | tst_Q*Application: add tests for unusual qApp creations and exits | 6.8 | qt/qtbase | Status: MERGED | +2 | 0 |