QSetting toList() crashes app in release mode



  • 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
    

  • Moderators

    @alexzh

    What Qt version and compiler are you using?

    note: I have added code tags to your post


  • Moderators

    @alexzh

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



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


  • Moderators

    @alexzh

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


  • Lifetime Qt Champion

    Hi,

    What does the stack trace of the crash return ?



  • 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,


  • Lifetime Qt Champion

    You can't.

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



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.