Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSetting toList() crashes app in release mode
QtWS25 Last Chance

QSetting toList() crashes app in release mode

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 3 Posters 1.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    alexzh
    wrote on last edited by koahnig
    #1

    Here is my very simple application (~10 lines) that crashes in release mode but works in debug on Win7.
    What’s wrong?
    The crash happens at the moment of leaving foo() function and it’s related to QList destruction.

    Thank you,

    #include <QApplication>
    #include <QSettings>
    
    void foo(QSettings& settings)
    {
    	settings.beginGroup("test_widget");
    	QList<QVariant> co = settings.value("column_order").toList();
    	settings.endGroup();
    }
    
    int main(int argc, char** argv)
    {
        QApplication app(argc, argv);
    
        QSettings settings("c:/temp/test.txt", QSettings::IniFormat);
        foo(settings);
    
        return 0;
    }
    

    c:/temp/test.txt file:

    [test_widget]
    column_order=6, 5, 4, 3, 2, 1, 0, 7, 8, 9, 10, 11, 12
    
    K 2 Replies Last reply
    0
    • A alexzh

      Here is my very simple application (~10 lines) that crashes in release mode but works in debug on Win7.
      What’s wrong?
      The crash happens at the moment of leaving foo() function and it’s related to QList destruction.

      Thank you,

      #include <QApplication>
      #include <QSettings>
      
      void foo(QSettings& settings)
      {
      	settings.beginGroup("test_widget");
      	QList<QVariant> co = settings.value("column_order").toList();
      	settings.endGroup();
      }
      
      int main(int argc, char** argv)
      {
          QApplication app(argc, argv);
      
          QSettings settings("c:/temp/test.txt", QSettings::IniFormat);
          foo(settings);
      
          return 0;
      }
      

      c:/temp/test.txt file:

      [test_widget]
      column_order=6, 5, 4, 3, 2, 1, 0, 7, 8, 9, 10, 11, 12
      
      K Offline
      K Offline
      koahnig
      wrote on last edited by koahnig
      #2

      @alexzh

      What Qt version and compiler are you using?

      note: I have added code tags to your post

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      2
      • A alexzh

        Here is my very simple application (~10 lines) that crashes in release mode but works in debug on Win7.
        What’s wrong?
        The crash happens at the moment of leaving foo() function and it’s related to QList destruction.

        Thank you,

        #include <QApplication>
        #include <QSettings>
        
        void foo(QSettings& settings)
        {
        	settings.beginGroup("test_widget");
        	QList<QVariant> co = settings.value("column_order").toList();
        	settings.endGroup();
        }
        
        int main(int argc, char** argv)
        {
            QApplication app(argc, argv);
        
            QSettings settings("c:/temp/test.txt", QSettings::IniFormat);
            foo(settings);
        
            return 0;
        }
        

        c:/temp/test.txt file:

        [test_widget]
        column_order=6, 5, 4, 3, 2, 1, 0, 7, 8, 9, 10, 11, 12
        
        K Offline
        K Offline
        koahnig
        wrote on last edited by
        #3

        @alexzh

        No crashes with Qt 5.4.2 and Qt 5.7.1, both 32 bit MinGW on Win 10 64 bit

        Vote the answer(s) that helped you to solve your issue(s)

        1 Reply Last reply
        1
        • A Offline
          A Offline
          alexzh
          wrote on last edited by
          #4

          Qt5.7.0, Win7/64, build Release/x86 & Debug/x86

          K 1 Reply Last reply
          0
          • A alexzh

            Qt5.7.0, Win7/64, build Release/x86 & Debug/x86

            K Offline
            K Offline
            koahnig
            wrote on last edited by
            #5

            @alexzh

            Compiler is one of MSVC or MinGw?
            Pre-build version installed or a self-compiled version of Qt 5.7.0?

            Vote the answer(s) that helped you to solve your issue(s)

            1 Reply Last reply
            1
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi,

              What does the stack trace of the crash return ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1
              • A Offline
                A Offline
                alexzh
                wrote on last edited by
                #7

                I build it with vs2015 and run using bat-file:
                PATH=%PATH%;C:\Qt\Qt5.7.0\5.7\msvc2015\bin;
                QtTest1
                Debug works fine, release crashes.
                Here is stack trace at the moment of crash:
                ntdll.dll!77e6e43e() Unknown
                [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
                ntdll.dll!77e6e0a3() Unknown
                ucrtbase.dll!70eb5eab() Unknown

                QtTest1.exe!operator delete(void * block, unsigned int __formal) Line 15 C++
                QtTest1.exe!QList<QVariant>::dealloc(QListData::Data * data) Line 861 C++
                QtTest1.exe!foo(QSettings & settings) Line 9 C++
                QtTest1.exe!main(int argc, char * * argv) Line 18 C++
                QtTest1.exe!__scrt_common_main_seh() Line 255 C++
                kernel32.dll!772b336a() Unknown
                ntdll.dll!77e79902() Unknown
                ntdll.dll!77e798d5() Unknown

                I can provide project file but I can just add it as text because I don't know how to attach file to message.
                Thank you,

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  You can't.

                  Depending on the size of it, you can using a service like pastebin.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    alexzh
                    wrote on last edited by
                    #9

                    The problem was in using debug Qt libraries for release build. Using correct libraries eliminates the problem. Thank you

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved