Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-133206

QThreadPrivate saying "QThreadStorage: Thread %p exited after QThreadStorage %d destroyed"

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • P1: Critical
    • None
    • 6.9.0 Beta2
    • Core: Threads
    • None
    • e0a1f4915 (dev), bcc0e6124 (6.9), 12d4bf1ab (6.8), e32f28034 (dev), d5c5f9f35 (6.9), 2ef615228 (6.8)

    Description

      Consider the following code:

      #include <QCoreApplication>
      #include <QLocale>
      #include <QThreadStorage>
      #include <QTimer>
      #include <QtGlobal>
      
      using ParseCache = QThreadStorage<int>;
      Q_GLOBAL_STATIC(ParseCache, sGlobalParse)
      
      class Tester
      {
      public:
          ~Tester()
          {
              QLocale().name();
              sGlobalParse->localData();
          }
      };
      
      Q_GLOBAL_STATIC(Tester, globalTestObject)
      
      int main(int argc, char **argv)
      {
          QCoreApplication app(argc, argv);
      
          Tester *t = globalTestObject();
          QTimer::singleShot(0, qApp, SLOT(quit()));
          return app.exec();
      } 

      With Qt 6.9 Beta 2 it crashes on exit

      ASSERT failure in QGlobalStatic<Holder>::Type& QGlobalStatic<Holder>::operator*() [with Holder = QtGlobalStatic::Holder<\{anonymous}::Q_QGS_defaultLocalePrivate>; Type = QSharedDataPointer<QLocalePrivate>]: "The global static was used after being destroyed", file /home/nico/workspace/qt6-dev/qtbase/src/corelib/global/qglobalstatic.h, line 92

       

      #0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
      
      #1  0x00007ffff5a9a1c3 in __pthread_kill_internal (threadid=<optimized out>, signo=6) at pthread_kill.c:78
      
      #2  0x00007ffff5a41436 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
      
      #3  0x00007ffff5a2891a in __GI_abort () at abort.c:79
      
      #4  0x00007ffff63ab96c in qAbort () at /home/nico/workspace/qt6-dev/qtbase/src/corelib/global/qassert.cpp:46
      
      #5  0x00007ffff6403666 in qt_message_fatal<QString&> (context=..., message=...) at /home/nico/workspace/qt6-dev/qtbase/src/corelib/global/qlogging.cpp:2149
      
      #6  0x00007ffff6404e91 in qt_message(QtMsgType, const QMessageLogContext &, const char *, typedef __va_list_tag __va_list_tag *) (msgType=msgType@entry=QtFatalMsg, context=..., msg=msg@entry=0x7ffff6efc460 "ASSERT failure in %s: \"%s\", file %s, line %d",  
          ap=ap@entry=0x7ffff3004c20) at /home/nico/workspace/qt6-dev/qtbase/src/corelib/global/qlogging.cpp:381
      
      #7  0x00007ffff641343f in QMessageLogger::fatal (this=this@entry=0x7ffff2e21da0, msg=msg@entry=0x7ffff6efc460 "ASSERT failure in %s: \"%s\", file %s, line %d") at /home/nico/workspace/qt6-dev/qtbase/src/corelib/global/qlogging.cpp:883
      
      #8  0x00007ffff63abc4b in qt_assert_x (where=where@entry=0x7ffff6f73140 "QGlobalStatic<Holder>::Type& QGlobalStatic<Holder>::operator*() [with Holder = QtGlobalStatic::Holder<{anonymous}::Q_QGS_defaultLocalePrivate>; Type = QSharedDataPointer<QLocalePrivate>]",  
          what=what@entry=0x7ffff6f73000 "The global static was used after being destroyed", file=file@entry=0x7ffff6f72f80 "/home/nico/workspace/qt6-dev/qtbase/src/corelib/global/qglobalstatic.h", line=line@entry=92)
      
          at /home/nico/workspace/qt6-dev/qtbase/src/corelib/global/qassert.cpp:114
      
      #9  0x00007ffff6833934 in QGlobalStatic<QtGlobalStatic::Holder<(anonymous namespace)::Q_QGS_defaultLocalePrivate> >::operator* (this=this@entry=0x7ffff72b4ce0 <defaultLocalePrivate>) at /home/nico/workspace/qt6-dev/qtbase/src/corelib/global/qglobalstatic.h:92
      
      #10 0x00007ffff683394e in QLocale::QLocale (this=this@entry=0x7ffff2e21d20) at /home/nico/workspace/qt6-dev/qtbase/src/corelib/text/qlocale.cpp:1214
      
      #11 0x00007ffff6514058 in QResourceFileEnginePrivate::QResourceFileEnginePrivate (this=0x508000000320, q=<optimized out>) at /home/nico/workspace/qt6-dev/qtbase/src/corelib/io/qresource.cpp:1401
      
      #12 0x00007ffff650de5d in QResourceFileEngine::QResourceFileEngine (this=this@entry=0x502000000770, file=...) at /home/nico/workspace/qt6-dev/qtbase/src/corelib/io/qresource.cpp:1416
      
      #13 0x00007ffff64bd53c in std::make_unique<QResourceFileEngine, QString const&> () at /usr/include/c++/14/bits/unique_ptr.h:1077
      
      #14 0x00007ffff64bb710 in _q_createLegacyEngine_recursive (entry=..., data=..., engine=std::unique_ptr<QAbstractFileEngine> = {...}, resolvingEntry=resolvingEntry@entry=false) at /home/nico/workspace/qt6-dev/qtbase/src/corelib/io/qfilesystemengine.cpp:129
      
      #15 0x00007ffff64bc033 in QFileSystemEngine::createLegacyEngine (entry=..., data=...) at /home/nico/workspace/qt6-dev/qtbase/src/corelib/io/qfilesystemengine.cpp:183
      
      #16 0x00007ffff64aea78 in QFileInfo::exists (path=...) at /home/nico/workspace/qt6-dev/qtbase/src/corelib/io/qfileinfo.cpp:752
      
      #17 0x00007ffff6493dc7 in QFile::exists (fileName=...) at /home/nico/workspace/qt6-dev/qtbase/src/corelib/io/qfile.cpp:370
      
      #18 0x00007ffff63f7131 in findConfiguration () at /home/nico/workspace/qt6-dev/qtbase/src/corelib/global/qlibraryinfo.cpp:106
      
      #19 0x00007ffff63f7a38 in QLibrarySettings::load (this=this@entry=0x7ffff72af520 <QGlobalStatic<QtGlobalStatic::Holder<(anonymous namespace)::Q_QGS_qt_library_settings> >::instance()::holder>)
      
          at /home/nico/workspace/qt6-dev/qtbase/src/corelib/global/qlibraryinfo.cpp:79
      
      #20 0x00007ffff63f7cf7 in QLibrarySettings::QLibrarySettings (this=0x7ffff72af520 <QGlobalStatic<QtGlobalStatic::Holder<(anonymous namespace)::Q_QGS_qt_library_settings> >::instance()::holder>)
      
          at /home/nico/workspace/qt6-dev/qtbase/src/corelib/global/qlibraryinfo.cpp:59
      
      #21 0x00007ffff63f7d33 in (anonymous namespace)::Q_QGS_qt_library_settings::innerFunction (pointer=<optimized out>) at /home/nico/workspace/qt6-dev/qtbase/src/corelib/global/qlibraryinfo.cpp:55
      
      #22 QtGlobalStatic::Holder<(anonymous namespace)::Q_QGS_qt_library_settings>::Holder (this=<optimized out>) at /home/nico/workspace/qt6-dev/qtbase/src/corelib/global/qglobalstatic.h:37
      
      #23 0x00007ffff63f7da9 in QGlobalStatic<QtGlobalStatic::Holder<(anonymous namespace)::Q_QGS_qt_library_settings> >::instance () at /home/nico/workspace/qt6-dev/qtbase/src/corelib/global/qglobalstatic.h:100
      
      #24 0x00007ffff63f7e29 in QGlobalStatic<QtGlobalStatic::Holder<(anonymous namespace)::Q_QGS_qt_library_settings> >::operator() (this=this@entry=0x7ffff72af5a0 <qt_library_settings>) at /home/nico/workspace/qt6-dev/qtbase/src/corelib/global/qglobalstatic.h:82
      
      #25 0x00007ffff63f8f65 in havePaths () at /home/nico/workspace/qt6-dev/qtbase/src/corelib/global/qlibraryinfo.cpp:148
      
      #26 0x00007ffff63fa746 in QLibraryInfoPrivate::paths (p=p@entry=QLibraryInfo::DataPath, usageMode=usageMode@entry=QLibraryInfoPrivate::RegularUsage) at /home/nico/workspace/qt6-dev/qtbase/src/corelib/global/qlibraryinfo.cpp:610
      
      #27 0x00007ffff63fbc70 in QLibraryInfoPrivate::path (p=p@entry=QLibraryInfo::DataPath, usageMode=usageMode@entry=QLibraryInfoPrivate::RegularUsage) at /home/nico/workspace/qt6-dev/qtbase/src/corelib/global/qlibraryinfo.cpp:669
      
      #28 0x00007ffff63fbdeb in QLibraryInfo::path (p=p@entry=QLibraryInfo::DataPath) at /home/nico/workspace/qt6-dev/qtbase/src/corelib/global/qlibraryinfo.cpp:523
      
      #29 0x00007ffff64ef8ef in QLoggingRegistry::initializeRules (this=this@entry=0x7ffff72b0d60 <QGlobalStatic<QtGlobalStatic::Holder<(anonymous namespace)::Q_QGS_qtLoggingRegistry> >::instance()::holder>)
      
          at /home/nico/workspace/qt6-dev/qtbase/src/corelib/io/qloggingregistry.cpp:309
      
      #30 0x00007ffff64f0538 in QLoggingRegistry::QLoggingRegistry (this=0x7ffff72b0d60 <QGlobalStatic<QtGlobalStatic::Holder<(anonymous namespace)::Q_QGS_qtLoggingRegistry> >::instance()::holder>)
      
          at /home/nico/workspace/qt6-dev/qtbase/src/corelib/io/qloggingregistry.cpp:239
      
      #31 0x00007ffff64f05f1 in (anonymous namespace)::Q_QGS_qtLoggingRegistry::innerFunction (pointer=<optimized out>) at /home/nico/workspace/qt6-dev/qtbase/src/corelib/io/qloggingregistry.cpp:29
      
      #32 QtGlobalStatic::Holder<(anonymous namespace)::Q_QGS_qtLoggingRegistry>::Holder (this=<optimized out>) at /home/nico/workspace/qt6-dev/qtbase/src/corelib/global/qglobalstatic.h:37
      
      #33 0x00007ffff64f0667 in QGlobalStatic<QtGlobalStatic::Holder<(anonymous namespace)::Q_QGS_qtLoggingRegistry> >::instance () at /home/nico/workspace/qt6-dev/qtbase/src/corelib/global/qglobalstatic.h:100
      
      #34 0x00007ffff64f06e7 in QGlobalStatic<QtGlobalStatic::Holder<(anonymous namespace)::Q_QGS_qtLoggingRegistry> >::operator() (this=this@entry=0x7ffff72b0ec0 <qtLoggingRegistry>) at /home/nico/workspace/qt6-dev/qtbase/src/corelib/global/qglobalstatic.h:82
      
      #35 0x00007ffff64f070a in QLoggingRegistry::instance () at /home/nico/workspace/qt6-dev/qtbase/src/corelib/io/qloggingregistry.cpp:424
      
      #36 0x00007ffff64e9dcf in QLoggingCategory::init (this=0x7ffff72b0c60 <QGlobalStatic<QtGlobalStatic::Holder<(anonymous namespace)::Q_QGS_qtDefaultCategory> >::instance()::holder>, category=<optimized out>, severityLevel=QtDebugMsg)
      
          at /home/nico/workspace/qt6-dev/qtbase/src/corelib/io/qloggingcategory.cpp:188
      
      #37 0x00007ffff64e9e58 in QLoggingCategory::QLoggingCategory (this=<optimized out>, category=<optimized out>, enableForLevel=<optimized out>) at /home/nico/workspace/qt6-dev/qtbase/src/corelib/io/qloggingcategory.cpp:176
      
      #38 0x00007ffff64e9e7d in (anonymous namespace)::Q_QGS_qtDefaultCategory::innerFunction (pointer=<optimized out>) at /home/nico/workspace/qt6-dev/qtbase/src/corelib/io/qloggingcategory.cpp:10
      
      #39 QtGlobalStatic::Holder<(anonymous namespace)::Q_QGS_qtDefaultCategory>::Holder (this=<optimized out>) at /home/nico/workspace/qt6-dev/qtbase/src/corelib/global/qglobalstatic.h:37
      
      #40 0x00007ffff64e9ef3 in QGlobalStatic<QtGlobalStatic::Holder<(anonymous namespace)::Q_QGS_qtDefaultCategory> >::instance () at /home/nico/workspace/qt6-dev/qtbase/src/corelib/global/qglobalstatic.h:100
      
      #41 0x00007ffff64e9f73 in QGlobalStatic<QtGlobalStatic::Holder<(anonymous namespace)::Q_QGS_qtDefaultCategory> >::operator() (this=this@entry=0x7ffff72b0ca0 <qtDefaultCategory>) at /home/nico/workspace/qt6-dev/qtbase/src/corelib/global/qglobalstatic.h:82
      
      #42 0x00007ffff64ea1d6 in QLoggingCategory::defaultCategory () at /home/nico/workspace/qt6-dev/qtbase/src/corelib/io/qloggingcategory.cpp:317
      
      #43 0x00007ffff6404662 in qt_message_print (msgType=msgType@entry=QtWarningMsg, context=..., message=...) at /home/nico/workspace/qt6-dev/qtbase/src/corelib/global/qlogging.cpp:2103
      
      #44 0x00007ffff6404de4 in qt_message(QtMsgType, const QMessageLogContext &, const char *, typedef __va_list_tag __va_list_tag *) (msgType=msgType@entry=QtWarningMsg, context=...,  
          msg=msg@entry=0x7ffff7046cc0 "QThreadStorage: Thread %p exited after QThreadStorage %d destroyed", ap=ap@entry=0x7ffff3003420) at /home/nico/workspace/qt6-dev/qtbase/src/corelib/global/qlogging.cpp:378
      
      #45 0x00007ffff6412b39 in QMessageLogger::warning (this=this@entry=0x7ffff2e20840, msg=msg@entry=0x7ffff7046cc0 "QThreadStorage: Thread %p exited after QThreadStorage %d destroyed") at /home/nico/workspace/qt6-dev/qtbase/src/corelib/global/qlogging.cpp:633
      
      #46 0x00007ffff6ac1994 in QThreadStorageData::finish (p=0x50d0000000a8) at /home/nico/workspace/qt6-dev/qtbase/src/corelib/thread/qthreadstorage.cpp:160
      
      #47 0x00007ffff6a8e4c5 in operator() (__closure=__closure@entry=0x7ffff2d06160) at /home/nico/workspace/qt6-dev/qtbase/src/corelib/thread/qthread_unix.cpp:423
      
      #48 0x00007ffff6a8e5c0 in (anonymous namespace)::terminate_on_exception<QThreadPrivate::finish()::<lambda()> >(struct {...} &&) (t=...) at /home/nico/workspace/qt6-dev/qtbase/src/corelib/thread/qthread_unix.cpp:325
      
      #49 0x00007ffff6a8e6a9 in QThreadPrivate::finish (this=this@entry=0x511000000180) at /home/nico/workspace/qt6-dev/qtbase/src/corelib/thread/qthread_unix.cpp:404
      
      #50 0x00007ffff6a8f9d8 in destroy_current_thread_data (p=0x50d000000040) at /home/nico/workspace/qt6-dev/qtbase/src/corelib/thread/qthread_unix.cpp:154
      
      #51 0x00007ffff6a8fa52 in Cleanup::~Cleanup (this=<optimized out>, __in_chrg=<optimized out>) at /home/nico/workspace/qt6-dev/qtbase/src/corelib/thread/qthread_unix.cpp:204
      
      #52 0x00007ffff5a43eb1 in __run_exit_handlers (status=0, listp=0x7ffff5bfc680 <__exit_funcs>, run_list_atexit=run_list_atexit@entry=true, run_dtors=run_dtors@entry=true) at exit.c:108
      
      #53 0x00007ffff5a43f80 in __GI_exit (status=<optimized out>) at exit.c:138
      

      It worked until and including 6.9 Beta 1

      Bisected to https://codereview.qt-project.org/c/qt/qtbase/+/615204

      Found via unit tests from KConfig: https://invent.kde.org/frameworks/kconfig/-/jobs/2499176

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            thiago Thiago Macieira
            nicolasfella Nicolas Fella
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: