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

Crash: one instance of QFileSystemWatcher used from many threads

    XMLWordPrintable

Details

    • 2948d282ce6518d1befd3e1d3371089a9863cac8 (qt-creator/qt-creator/6.0)

    Description

      The reason is that the same instance of QFileSystemWatcher is used directly form different threads:

      1  QFileSystemWatcher::addPaths                                                                                                                                                                                                                                                                                                                                                                                              qfilesystemwatcher.cpp   354 0x7ffff5b2d6b3 
      2  Core::addFileInfos                                                                                                                                                                                                                                                                                                                                                                                                        documentmanager.cpp      352 0x7fffd93005ad 
      3  Core::DocumentManager::addDocuments                                                                                                                                                                                                                                                                                                                                                                                       documentmanager.cpp      393 0x7fffd9300e0a 
      4  Core::DocumentManager::addDocument                                                                                                                                                                                                                                                                                                                                                                                        documentmanager.cpp      521 0x7fffd9301a58 
      5  ResourceEditor::ResourceTopLevelNode::ResourceTopLevelNode                                                                                                                                                                                                                                                                                                                                                                resourcenode.cpp         256 0x7fffe0138ac6 
      6  std::make_unique<ResourceEditor::ResourceTopLevelNode, Utils::FilePath const&, Utils::FilePath const&>                                                                                                                                                                                                                                                                                                                    unique_ptr.h             962 0x7fffe013233d 
      7  operator()                                                                                                                                                                                                                                                                                                                                                                                                                resourceeditorplugin.cpp 261 0x7fffe012f12d 
      8  std::__invoke_impl<void, ResourceEditor::Internal::ResourceEditorPlugin::extensionsInitialized()::<lambda(ProjectExplorer::FolderNode *)>&, ProjectExplorer::FolderNode *>(std::__invoke_other, struct {...} &)                                                                                                                                                                                                           invoke.h                 61  0x7fffe01310e2 
      9  std::__invoke_r<void, ResourceEditor::Internal::ResourceEditorPlugin::extensionsInitialized()::<lambda(ProjectExplorer::FolderNode *)>&, ProjectExplorer::FolderNode *>(struct {...} &)                                                                                                                                                                                                                                   invoke.h                 111 0x7fffe0130edc 
      10 std::_Function_handler<void(ProjectExplorer::FolderNode *), ResourceEditor::Internal::ResourceEditorPlugin::extensionsInitialized()::<lambda(ProjectExplorer::FolderNode *)>>::_M_invoke(const std::_Any_data &, ProjectExplorer::FolderNode *&&)                                                                                                                                                                         std_function.h           291 0x7fffe0130c5e 
      11 std::function<void (ProjectExplorer::FolderNode *)>::operator()(ProjectExplorer::FolderNode *) const                                                                                                                                                                                                                                                                                                                      std_function.h           560 0x7fffd87d180d 
      12 ProjectExplorer::ProjectTree::applyTreeManager                                                                                                                                                                                                                                                                                                                                                                            projecttree.cpp          411 0x7fffd87e5206 
      13 CMakeProjectManager::Internal::extractData                                                                                                                                                                                                                                                                                                                                                                                fileapidataextractor.cpp 760 0x7fffb67eb01b 
      14 operator()                                                                                                                                                                                                                                                                                                                                                                                                                fileapireader.cpp        257 0x7fffb6834469 
      15 Utils::Internal::runAsyncQFutureInterfaceDispatch<std::shared_ptr<CMakeProjectManager::Internal::FileApiQtcData>, CMakeProjectManager::Internal::FileApiReader::endState(const Utils::FilePath&, bool)::<lambda(QFutureInterface<std::shared_ptr<CMakeProjectManager::Internal::FileApiQtcData>>&)>>(std::true_type, QFutureInterface<std::shared_ptr<CMakeProjectManager::Internal::FileApiQtcData>> &, struct {...} &&) runextensions.h          257 0x7fffb683788c 
      16 Utils::Internal::runAsyncMemberDispatch<std::shared_ptr<CMakeProjectManager::Internal::FileApiQtcData>, CMakeProjectManager::Internal::FileApiReader::endState(const Utils::FilePath&, bool)::<lambda(QFutureInterface<std::shared_ptr<CMakeProjectManager::Internal::FileApiQtcData>>&)>>(QFutureInterface<std::shared_ptr<CMakeProjectManager::Internal::FileApiQtcData>> &, struct {...} &&)                           runextensions.h          274 0x7fffb683784c 
      17 Utils::Internal::runAsyncImpl<std::shared_ptr<CMakeProjectManager::Internal::FileApiQtcData>, CMakeProjectManager::Internal::FileApiReader::endState(const Utils::FilePath&, bool)::<lambda(QFutureInterface<std::shared_ptr<CMakeProjectManager::Internal::FileApiQtcData>>&)>>(QFutureInterface<std::shared_ptr<CMakeProjectManager::Internal::FileApiQtcData>> &, struct {...} &&)                                     runextensions.h          303 0x7fffb6837801 
      18 Utils::Internal::AsyncJob<std::shared_ptr<CMakeProjectManager::Internal::FileApiQtcData>, CMakeProjectManager::Internal::FileApiReader::endState(const Utils::FilePath&, bool)::<lambda(QFutureInterface<std::shared_ptr<CMakeProjectManager::Internal::FileApiQtcData>>&)>>::runHelper<0>(std::index_sequence)                                                                                                           runextensions.h          372 0x7fffb683776e 
      19 Utils::Internal::AsyncJob<std::shared_ptr<CMakeProjectManager::Internal::FileApiQtcData>, CMakeProjectManager::Internal::FileApiReader::endState(const Utils::FilePath&, bool)::<lambda(QFutureInterface<std::shared_ptr<CMakeProjectManager::Internal::FileApiQtcData>>&)>>::run(void)                                                                                                                                   runextensions.h          352 0x7fffb68376a5 
      20 QThreadPoolThread::run                                                                                                                                                                                                                                                                                                                                                                                                    qthreadpool.cpp          99  0x7ffff5aabf40 
      

      Please note that destructor of ResourceTopLevelNode may also be potentially called from non-main thread in case the cmake parsing is canceled. In this case the whole CMakeProjectNode hierarchy (including instances of ResourceTopLevelNode) may be destructed directly from the parser thread. Destructor of ResourceTopLevelNode also makes a call to the same QFileSystemWatcher instance.

      Besides, a call to DocumentManager::addDocument() from non-main thread doesn't look safe. In addition, ResourceFileWatcher document is a subclass of QObject, so when it's being created in non-main thread it will still be living there even when the node hierarchy is returned to the main thread.

      Probably introduced in 0bcab32657f1511892eda53194dce259e40edf21

      Attachments

        Issue Links

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

          Activity

            People

              jkobus Jarek Kobus
              jkobus Jarek Kobus
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes