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

Possible crash in ShellCommand on shutdown

    XMLWordPrintable

Details

    • bcd3feeaa70e4e2b1eb8751614f0b436873309c6 (qt-creator/qt-creator/master)

    Description

      To reproduce:
      1. Apply this patch https://codereview.qt-project.org/c/qt-creator/qt-creator/+/349547
      2. Load a project into creator. Invoke some ShellCommand, like Tools | Git | Current File | Log.
      3. As soon as you see the "Shutdown now" printout, close creator. It should crash.

      The reason is that the running command is not stopped on Creator shutdown, and there is no code which would wait for the command to finish on Creator shutdown. The ShellCommand is designed in a way, that when it finishes it deletes itself. So the case of closing the Creator when a command is being executed was not taken into account. This needs some refactoring.

      Call stack

                                                                                                                                                                                                                                                                                                                                                             
                                                                                                                                                                                                                                                                                                                                                             
      1  raise                                                                                                                                                                                                                                                                                                                                0x7ffff5ad4292 
      2  abort                                                                                                                                                                                                                                                                                                                                0x7ffff5abd8a4 
      3  qt_message_fatal                                                                                                                                                                                                                                                                                          qlogging.cpp          1914 0x7ffff60bbf47 
      4  QMessageLogger::fatal                                                                                                                                                                                                                                                                                     qlogging.cpp          893  0x7ffff60b836a 
      5  qt_assert_x                                                                                                                                                                                                                                                                                               qglobal.cpp           3366 0x7ffff60af8b2 
      6  QWidgetPrivate::init                                                                                                                                                                                                                                                                                      qwidget.cpp           998  0x7ffff73f80c9 
      7  QWidget::QWidget                                                                                                                                                                                                                                                                                          qwidget.cpp           903  0x7ffff73f7afb 
      8  QAbstractButton::QAbstractButton                                                                                                                                                                                                                                                                          qabstractbutton.cpp   525  0x7ffff75096c3 
      9  QToolButton::QToolButton                                                                                                                                                                                                                                                                                  qtoolbutton.cpp       192  0x7ffff763edef 
      10 Core::CommandButton::CommandButton                                                                                                                                                                                                                                                                        commandbutton.cpp     58   0x7fffcd01c848 
      11 Core::IOutputPane::IOutputPane                                                                                                                                                                                                                                                                            outputpanemanager.cpp 94   0x7fffcd20c88b 
      12 VcsBase::VcsOutputWindow::VcsOutputWindow                                                                                                                                                                                                                                                                 vcsoutputwindow.cpp   312  0x7fffbdb98477 
      13 VcsBase::VcsOutputWindow::instance                                                                                                                                                                                                                                                                        vcsoutputwindow.cpp   497  0x7fffbdb99356 
      14 operator()                                                                                                                                                                                                                                                                                                vcscommand.cpp        47   0x7fffbdb944d4 
      15 std::__invoke_impl<Utils::OutputProxy *, VcsBase::VcsCommand::VcsCommand(const QString&, const Utils::Environment&)::<lambda()>&>(std::__invoke_other, struct {...} &)                                                                                                                                    invoke.h              61   0x7fffbdb95220 
      16 std::__invoke_r<Utils::OutputProxy *, VcsBase::VcsCommand::VcsCommand(const QString&, const Utils::Environment&)::<lambda()>&>(struct {...} &)                                                                                                                                                            invoke.h              114  0x7fffbdb94fd4 
      17 std::_Function_handler<Utils::OutputProxy *(), VcsBase::VcsCommand::VcsCommand(const QString&, const Utils::Environment&)::<lambda()>>::_M_invoke(const std::_Any_data &)                                                                                                                                 std_function.h        291  0x7fffbdb94da1 
      18 std::function<Utils::OutputProxy * ()>::operator()() const                                                                                                                                                                                                                                                std_function.h        560  0x7ffff7d6d41a 
      19 Utils::ShellCommand::runCommand(Utils::SynchronousProcess&, Utils::CommandLine const&, int, QString const&, std::function<Utils::QtcProcess::Result (int)> const&)                                                                                                                                        shellcommand.cpp      323  0x7ffff7d6b3ac 
      20 VcsBase::VcsCommand::runCommand(Utils::SynchronousProcess&, Utils::CommandLine const&, int, QString const&, std::function<Utils::QtcProcess::Result (int)> const&)                                                                                                                                        vcscommand.cpp        85   0x7fffbdb94972 
      21 Utils::ShellCommand::run                                                                                                                                                                                                                                                                                  shellcommand.cpp      279  0x7ffff7d6b00e 
      22 Utils::Internal::MemberCallable<void (Utils::ShellCommand:: *)(QFutureInterface<void>&)>::operator()                                                                                                                                                                                                      runextensions.h       227  0x7ffff7d6f252 
      23 Utils::Internal::runAsyncQFutureInterfaceDispatch<void, Utils::Internal::MemberCallable<void (Utils::ShellCommand:: *)(QFutureInterface<void>&)>>(std::integral_constant<bool, true>, QFutureInterface<void>, Utils::Internal::MemberCallable<void (Utils::ShellCommand:: *)(QFutureInterface<void>&)>&&) runextensions.h       257  0x7ffff7d6f1d4 
      24 Utils::Internal::runAsyncMemberDispatch<void, Utils::Internal::MemberCallable<void (Utils::ShellCommand:: *)(QFutureInterface<void>&)>, , void>(QFutureInterface<void>, Utils::Internal::MemberCallable<void (Utils::ShellCommand:: *)(QFutureInterface<void>&)>&&)                                       runextensions.h       274  0x7ffff7d6f183 
      25 Utils::Internal::runAsyncImpl<void, Utils::Internal::MemberCallable<void (Utils::ShellCommand:: *)(QFutureInterface<void>&)>>(QFutureInterface<void>, Utils::Internal::MemberCallable<void (Utils::ShellCommand:: *)(QFutureInterface<void>&)>&&)                                                         runextensions.h       303  0x7ffff7d6f0e9 
      26 Utils::Internal::runAsyncMemberDispatch<void, void (Utils::ShellCommand:: *)(QFutureInterface<void>&), Utils::ShellCommand *, , void>(QFutureInterface<void>, void (Utils::ShellCommand:: *&&)(QFutureInterface<void>&), Utils::ShellCommand *&&)                                                         runextensions.h       285  0x7ffff7d6f001 
      27 Utils::Internal::runAsyncImpl<void, void (Utils::ShellCommand:: *)(QFutureInterface<void>&), Utils::ShellCommand *>                                                                                                                                                                                       runextensions.h       303  0x7ffff7d6ef30 
      28 Utils::Internal::AsyncJob<void, void (Utils::ShellCommand:: *)(QFutureInterface<void>&), Utils::ShellCommand *>::runHelper<0ul, 1ul>                                                                                                                                                                      runextensions.h       372  0x7ffff7d6ee1c 
      29 Utils::Internal::AsyncJob<void, void (Utils::ShellCommand:: *)(QFutureInterface<void>&), Utils::ShellCommand *>::run                                                                                                                                                                                      runextensions.h       352  0x7ffff7d6ecfe 
      30 Utils::Internal::RunnableThread::run                                                                                                                                                                                                                                                                      runextensions.cpp     39   0x7ffff7d5ca95 
      31 QThreadPrivate::start                                                                                                                                                                                                                                                                                     qthread_unix.cpp      329  0x7ffff60c6ed3 
      32 start_thread                                                                                                                                                                                                                                                                                                                         0x7ffff52b1299 
      33 clone                                                                                                                                                                                                                                                                                                                                0x7ffff5b976a3 
      

      Call stack that triggers the Log command, the main thread:

      1 VcsBase::VcsBaseClientImpl::enqueueJob(VcsBase::VcsCommand *, QStringList const&, QString const&, std::function<Utils::QtcProcess::Result (int)> const&) const vcsbaseclient.cpp 119  0x7fffc5b4e0fd 
      2 VcsBase::VcsBaseClientImpl::vcsExec                                                                                                                            vcsbaseclient.cpp 203  0x7fffc5b4e83f 
      3 Git::Internal::GitClient::log                                                                                                                                  gitclient.cpp     1153 0x7fffc4172ede 
      4 Git::Internal::GitPluginPrivate::logFile                                                                                                                       gitplugin.cpp     1050 0x7fffc41bb781 
      

      Please note, that the VcsCommand created inside VcsBase::VcsBaseClientImpl::vcsExec() is not used in Git::Internal::GitClient::log(), so no handle for it is stored in main thread from now.

      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:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes