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

QSettings hangs an application on 20-30 seconds after system reboot

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.11.0
    • 5.9.1
    • Core: I/O
    • None
    • * Embedded Toradex iMX6 board
       * Linux: Linux TORA-DEX 3.14.52-00011-g9f2723e-dirty #11 SMP Mon Mar 6 13:52:01 MSK 2017 armv7l GNU/Linux
       * GCC 5.4
       * Qt 5.9.1 ARM (self build)
    • 772863355a0cf57a49e93608790dfd17c8fd82da

    Description

      My application uses QSettings to store periodically (every ~100 msec) some values to *.ini files. Also, my application starts automatically on embedded board by some init scripts after the system reboot (always starts with root rights). But, sometimes, when the system reboots on a power, then the application hangs within ~20-30 seconds.

      I use following code:

      #include <QCoreApplication>
      #include <QSettings>
      #include <QTimer>
      #include <QDebug>
      #include <QDateTime>
      
      const char kParameterKey[] = "Parameter";
      const int kTimerInterval = 100;
      
      int main(int argc, char *argv[])
      {
          QCoreApplication a(argc, argv);
      
          qDebug() << "Current date" << QDateTime::currentDateTime(); // has been added 
      
          const QString inifile = qApp->applicationDirPath() + QLatin1String("/settings-bug.ini");
          QSettings settings(inifile, QSettings::IniFormat);
      
          auto parameter = settings.value(QLatin1String(kParameterKey)).toInt();
      
          QTimer timer;
          QCoreApplication::connect(&timer, &QTimer::timeout, [&settings, &parameter]() {
              ++parameter;
              settings.setValue(QLatin1String(kParameterKey), parameter);
              qDebug() << "Update" << parameter;
          });
          timer.start(kTimerInterval);
      
          return a.exec();
      }
      

      I see, that after almost of every rebooting, the QSettings creates a set of new 'lock' files, like: 

      settings-bug.ini.lock
      settings-bug.ini.UVd200
      settings-bug.ini.FVs201
      ...
      settings-bug.ini.yJH201When no any hangs occurred, I see following output:
      Update 136
      QLockFile: Lock file '/home/root/settings-bug.ini.lock' has a modification time in the future
      Update 137
      Update 138
      ...
      Update 142
      Update 143
      

      But, when hangs occurred, I see following output:

      Update 143
      <here hangs on 20-30 second>
      Update 144
      Update 145
      ...

      As I understand, this 'hang' comes from QLockFile which is uses inside of QSettings, and this 20-30 seconds is "default locking timeout" (yes?). But QSettings does not provide an API to control this 'locking timeout'.

      PS: I have attached the source project example.

      Attachments

        1. booting-log.txt
          121 kB
        2. qtbug63425.tar
          4 kB

        Issue Links

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

          Activity

            People

              thiago Thiago Macieira
              kuzulis Denis Shienkov
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes