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

Crash on CMake completion

    XMLWordPrintable

Details

    • All
    • 07e758147 (12.0), 3956d5b27 (12.0)

    Description

      Apply the following patch: https://codereview.qt-project.org/c/qt-creator/qt-creator/+/508693.

      In order to reproduce:
      1. Open any CMakeLists.txt file.
      2. Position a cursor inside e.g. "INCLUDES".
      3. Press Ctrl+Space to induce a completion.
      4. Quickly (within 10 seconds) close Creator -> crash.

      The call stack:

      1  std::__atomic_base<QThreadData *>::load                                                                                                                                                                                                                                                                                                                                                                                                                            atomic_base.h                    820  0x7ffff4b73a47 
      2  std::atomic<QThreadData *>::load                                                                                                                                                                                                                                                                                                                                                                                                                                   atomic                           578  0x7ffff4b73a47 
      3  QAtomicOps<QThreadData *>::loadAcquire<QThreadData *>                                                                                                                                                                                                                                                                                                                                                                                                              qatomic_cxx11.h                  213  0x7ffff4b73167 
      4  QBasicAtomicPointer<QThreadData>::loadAcquire                                                                                                                                                                                                                                                                                                                                                                                                                      qbasicatomic.h                   181  0x7ffff4b72894 
      5  QObjectPrivate::connectImpl                                                                                                                                                                                                                                                                                                                                                                                                                                        qobject.cpp                      5131 0x7ffff4c0e02c 
      6  QObject::connectImpl                                                                                                                                                                                                                                                                                                                                                                                                                                               qobject.cpp                      5062 0x7ffff4c0daf7 
      7  QObject::connect<void (CMakeProjectManager::CMakeToolManager:: *)(const Utils::Id&), CMakeProjectManager::CMakeToolManager::defaultProjectOrDefaultCMakeTool()::<lambda()>>(const QtPrivate::FunctionPointer<void (CMakeProjectManager::CMakeToolManager:: *)(Utils::Id const&)>::Object *, void (CMakeProjectManager::CMakeToolManager:: *)(CMakeProjectManager::CMakeToolManager * const, const Utils::Id &), const QObject *, struct {...}, Qt::ConnectionType) qobject.h                        312  0x7fff7d82766e 
      8  CMakeProjectManager::CMakeToolManager::defaultProjectOrDefaultCMakeTool                                                                                                                                                                                                                                                                                                                                                                                            cmaketoolmanager.cpp             263  0x7fff7d825ae8 
      9  CMakeProjectManager::Internal::CMakeFileCompletionAssist::performAsync                                                                                                                                                                                                                                                                                                                                                                                             cmakefilecompletionassist.cpp    256  0x7fff7d76a970 
      10 operator()                                                                                                                                                                                                                                                                                                                                                                                                                                                         asyncprocessor.cpp               26   0x7fffd431c333 
      11 std::__invoke_impl<TextEditor::IAssistProposal *, TextEditor::AsyncProcessor::perform()::<lambda()>&>(std::__invoke_other, struct {...} &)                                                                                                                                                                                                                                                                                                                         invoke.h                         61   0x7fffd431d3fd 
      12 std::__invoke<TextEditor::AsyncProcessor::perform()::<lambda()>&>(struct {...} &)                                                                                                                                                                                                                                                                                                                                                                                  invoke.h                         96   0x7fffd431d384 
      13 std::invoke<TextEditor::AsyncProcessor::perform()::<lambda()>&>(struct {...} &)                                                                                                                                                                                                                                                                                                                                                                                    functional                       97   0x7fffd431d2d9 
      14 operator()                                                                                                                                                                                                                                                                                                                                                                                                                                                         qtconcurrentstoredfunctioncall.h 116  0x7fffd431d1b0 
      15 std::__invoke_impl<TextEditor::IAssistProposal *, const QtConcurrent::StoredFunctionCall<TextEditor::AsyncProcessor::perform()::<lambda()>>::runFunctor()::<lambda(std::decay_t<TextEditor::AsyncProcessor::perform()::<lambda()>>)>&, TextEditor::AsyncProcessor::perform()::<lambda()>>(std::__invoke_other, const struct {...} &)                                                                                                                               invoke.h                         61   0x7fffd431d3d7 
      16 std::__invoke<const QtConcurrent::StoredFunctionCall<TextEditor::AsyncProcessor::perform()::<lambda()>>::runFunctor()::<lambda(std::decay_t<TextEditor::AsyncProcessor::perform()::<lambda()>>)>&, TextEditor::AsyncProcessor::perform()::<lambda()>>(const struct {...} &)                                                                                                                                                                                        invoke.h                         96   0x7fffd431d350 
      17 std::__apply_impl<const QtConcurrent::StoredFunctionCall<TextEditor::AsyncProcessor::perform()::<lambda()>>::runFunctor()::<lambda(std::decay_t<TextEditor::AsyncProcessor::perform()::<lambda()>>)>&, std::tuple<TextEditor::AsyncProcessor::perform()::<lambda()>>, 0>(const struct {...} &, std::tuple<TextEditor::AsyncProcessor::perform()::<lambda()>> &&, std::index_sequence)                                                                              tuple                            1854 0x7fffd431d1f1 
      18 std::apply<const QtConcurrent::StoredFunctionCall<TextEditor::AsyncProcessor::perform()::<lambda()>>::runFunctor()::<lambda(std::decay_t<TextEditor::AsyncProcessor::perform()::<lambda()>>)>&, std::tuple<TextEditor::AsyncProcessor::perform()::<lambda()>>>(const struct {...} &, std::tuple<TextEditor::AsyncProcessor::perform()::<lambda()>> &&)                                                                                                             tuple                            1865 0x7fffd431d22e 
      19 QtConcurrent::StoredFunctionCall<TextEditor::AsyncProcessor::perform()::<lambda()>>::runFunctor(void)                                                                                                                                                                                                                                                                                                                                                              qtconcurrentstoredfunctioncall.h 122  0x7fffd431d276 
      20 QtConcurrent::RunFunctionTaskBase<TextEditor::IAssistProposal *>::run                                                                                                                                                                                                                                                                                                                                                                                              qtconcurrentrunbase.h            83   0x7fffd431e0a8 
      21 QThreadPoolThread::run                                                                                                                                                                                                                                                                                                                                                                                                                                             qthreadpool.cpp                  66   0x7ffff4e363b8 
      22 operator()                                                                                                                                                                                                                                                                                                                                                                                                                                                         qthread_unix.cpp                 321  0x7ffff4e2e98f 
      23 (anonymous namespace)::terminate_on_exception<QThreadPrivate::start(void *)::<lambda()>>(struct {...} &&)                                                                                                                                                                                                                                                                                                                                                          qthread_unix.cpp                 257  0x7ffff4e2fc8b 
      24 QThreadPrivate::start                                                                                                                                                                                                                                                                                                                                                                                                                                              qthread_unix.cpp                 280  0x7ffff4e2ea5b 
      25 start_thread                                                                                                                                                                                                                                                                                                                                                                                                                                                       pthread_create.c                 442  0x7ffff4294b43 
      26 clone3                                                                                                                                                                                                                                                                                                                                                                                                                                                             clone3.S                         81   0x7ffff4326a00 
      

      The implementation of CMakeFileCompletionAssist::performAsync() doesn't look thread-safe.

      Update:
      It looks like there are more general issues with:

      IAssistProposal *AsyncProcessor::perform()
      {
          IAssistProposal *result = immediateProposal();
          interface()->prepareForAsyncUse();
          m_watcher.setFuture(Utils::asyncRun([this] {
              interface()->recreateTextDocument();
              return performAsync();
          }));
          return result;
      }
      

      1. There is lack of QFuture synchronization on Creator shutdown.
      2. It looks like when performAsync() is executed and the Creator shuts down, the AsyncProcessor is leaked.

      Attachments

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

        Activity

          People

            jkobus Jarek Kobus
            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