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

Intermittent crash due to stale argv reference

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Not Evaluated
    • 5.9.4
    • 5.6.1, 5.9.0
    • Core: Other
    • None
    • Windows 7
    • 9832f0ab857904a88c9b5e71a9e447abbebca8fb

    Description

      Given that an application want to create a QCoreApplication on demand and dispose it immediately after it is used

      when a second instance of the QCoreApplication is created

      then the application sometimes crash.

      The crash is hard to reproduce since it is dependent on the memory layout of the application when the second instance of QCoreApplication  is created.

      However, after debugging the issue it is assumed that  the root cause is a stale static pointer (procName)  set at the previous instance of QCoreApplicationPrivate.

      The produced in 5.6.1.

      It is assumed that it persists in 5.9.0 although not reproduced there.


      QString QCoreApplication::applicationFilePath()

      ..

          if (d->argc) {
              static const char *procName = d->argv[0]; <- Stale on second QCoreApplication instance
              if (qstrcmp(procName, d->argv[0]) != 0) { <- Crash
                  // clear the cache if the procname changes, so we reprocess it.
                  QCoreApplicationPrivate::clearApplicationFilePath();
                  procName = d->argv[0];
              }
          }

       

           ucrtbased.dll!strcmp() Line 105    Unknown
           Qt5Cored.dll!qstrcmp(const char * str1, const char * str2) Line 262    C++
      >    Qt5Cored.dll!QCoreApplication::applicationFilePath() Line 2127    C++
           Qt5Cored.dll!QCoreApplication::applicationDirPath() Line 2097    C++
           Qt5Cored.dll!QStandardPaths::standardLocations(QStandardPaths::StandardLocation type) Line 272    C++
           Qt5Cored.dll!QStandardPaths::locate(QStandardPaths::StandardLocation type, const QString & fileName, QFlags<enum QStandardPaths::LocateOption> options) Line 411    C++
           Qt5Cored.dll!QLoggingRegistry::init() Line 297    C++
           Qt5Cored.dll!QCoreApplicationPrivate::init() Line 782    C++
           Qt5Guid.dll!QGuiApplicationPrivate::init() Line 1269    C++
           Qt5Widgetsd.dll!QApplicationPrivate::init() Line 580    C++
           Qt5Widgetsd.dll!QApplication::QApplication(int & argc, char * * argv, int _internal) Line 571    C++

      Attachments

        Issue Links

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

          Activity

            People

              andysh Andy Shaw
              ebaklund Erik Baklund
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes