Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-25318

DirectoryFilter::refresh method is called on destructed object (crash)

    XMLWordPrintable

    Details

    • Commits:
      cb5977fbad51d035d05f441e78204f591a5a916f (qt-creator/qt-creator/master)

      Description

      To reproduce:

      Run creator and load a session containing creator project. Just after the start of loading quit creator. Here we are getting a crash on exit.

      It looks like DirectoryFilter m_allProjectDirectoriesFilter, which is a member field of ProjectExplorerPluginPrivate, is being destructed while (or before) its DirectoryFilter::refresh() is still being executed in the other thread.

      The stack trace:

      1  std::__atomic_base<int>::load                                                                                                                                                                                                                                                                                     atomic_base.h       426  0x7fffd18da608 
      2  QAtomicOps<int>::loadRelaxed<int>                                                                                                                                                                                                                                                                                 qatomic_cxx11.h     239  0x7fffd18da608 
      3  QBasicAtomicInteger<int>::loadRelaxed                                                                                                                                                                                                                                                                             qbasicatomic.h      107  0x7fffd18d9636 
      4  QtPrivate::RefCount::deref                                                                                                                                                                                                                                                                                        qrefcount.h         66   0x7fffd18d7d3a 
      5  QString::~QString                                                                                                                                                                                                                                                                                                 qstring.h           1311 0x7fffd18d8109 
      6  Utils::FilePath::~FilePath                                                                                                                                                                                                                                                                                        fileutils.h         66   0x7fffd18d8ae6 
      7  QList<Utils::FilePath>::node_destruct                                                                                                                                                                                                                                                                             qlist.h             524  0x7fffd1947b8c 
      8  QList<Utils::FilePath>::dealloc                                                                                                                                                                                                                                                                                   qlist.h             921  0x7fffd1946e11 
      9  QList<Utils::FilePath>::~QList                                                                                                                                                                                                                                                                                    qlist.h             874  0x7fffd194635e 
      10 QList<Utils::FilePath>::operator=                                                                                                                                                                                                                                                                                 qlist.h             533  0x7fffd1a4f17b 
      11 Core::DirectoryFilter::refresh                                                                                                                                                                                                                                                                                    directoryfilter.cpp 321  0x7fffd1a592ad 
      12 Utils::Internal::MemberCallable<void (Core::ILocatorFilter:: *)(QFutureInterface<void>&)>::operator()                                                                                                                                                                                                             runextensions.h     227  0x7fffd1a76942 
      13 Utils::Internal::runAsyncQFutureInterfaceDispatch<void, Utils::Internal::MemberCallable<void (Core::ILocatorFilter:: *)(QFutureInterface<void>&)>>(std::integral_constant<bool, true>, QFutureInterface<void>, Utils::Internal::MemberCallable<void (Core::ILocatorFilter:: *)(QFutureInterface<void>&)>&&)       runextensions.h     257  0x7fffd1a768c4 
      14 Utils::Internal::runAsyncMemberDispatch<void, Utils::Internal::MemberCallable<void (Core::ILocatorFilter:: *)(QFutureInterface<void>&)>, , void>(QFutureInterface<void>, Utils::Internal::MemberCallable<void (Core::ILocatorFilter:: *)(QFutureInterface<void>&)>&&)                                             runextensions.h     274  0x7fffd1a76803 
      15 Utils::Internal::runAsyncImpl<void, Utils::Internal::MemberCallable<void (Core::ILocatorFilter:: *)(QFutureInterface<void>&)>>(QFutureInterface<void>, Utils::Internal::MemberCallable<void (Core::ILocatorFilter:: *)(QFutureInterface<void>&)>&&)                                                               runextensions.h     303  0x7fffd1a765a9 
      16 Utils::Internal::runAsyncMemberDispatch<void, void (Core::ILocatorFilter:: * const&)(QFutureInterface<void>&), std::reference_wrapper<Core::ILocatorFilter *>, , void>(QFutureInterface<void>, void (Core::ILocatorFilter:: * const&)(QFutureInterface<void>&), std::reference_wrapper<Core::ILocatorFilter *>&&) runextensions.h     285  0x7fffd1a762af 
      17 Utils::Internal::runAsyncImpl<void, void (Core::ILocatorFilter:: * const)(QFutureInterface<void>&), std::reference_wrapper<Core::ILocatorFilter *>>                                                                                                                                                               runextensions.h     295  0x7fffd1a75f76 
      18 Utils::Internal::AsyncJob<void, std::reference_wrapper<void (Core::ILocatorFilter:: * const)(QFutureInterface<void>&)>, std::reference_wrapper<Core::ILocatorFilter *>>::runHelper<0ul, 1ul>                                                                                                                      runextensions.h     372  0x7fffd1a75cc0 
      19 Utils::Internal::AsyncJob<void, std::reference_wrapper<void (Core::ILocatorFilter:: * const)(QFutureInterface<void>&)>, std::reference_wrapper<Core::ILocatorFilter *>>::run                                                                                                                                      runextensions.h     352  0x7fffd1a75aac 
      20 QThreadPoolThread::run                                                                                                                                                                                                                                                                                            qthreadpool.cpp     100  0x7ffff60b71d1 
      21 QThreadPrivate::start                                                                                                                                                                                                                                                                                             qthread_unix.cpp    329  0x7ffff60b130e 
      22 start_thread                                                                                                                                                                                                                                                                                                                               0x7ffff53493f9 
      23 clone                                                                                                                                                                                                                                                                                                                                      0x7ffff5bb5903 
      

      When the https://codereview.qt-project.org/c/qt-creator/qt-creator/+/332884 is applied, the app output shows:

      DirectoryFilter c'tor Core::DirectoryFilter(0xbbfe10)
      DirectoryFilter refreshing... Core::DirectoryFilter(0xbbfe10)
      DirectoryFilter refreshing... Core::DirectoryFilter(0xbbfe10)
      DirectoryFilter refreshing... Core::DirectoryFilter(0xbbfe10)
      DirectoryFilter refreshing... Core::DirectoryFilter(0xbbfe10)
      DirectoryFilter refreshing... Core::DirectoryFilter(0xbbfe10)
      DirectoryFilter d'tor Core::DirectoryFilter(0xbbfe10)
      DirectoryFilter refreshing... QObject(0xbbfe10)
      

        Attachments

        For Gerrit Dashboard: QTCREATORBUG-25318
        # Subject Branch Project Status CR V

          Activity

            People

            Assignee:
            con Eike Ziller
            Reporter:
            jkobus Jarek Kobus
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes