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
-
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
-
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
-
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() UnknownQtTest1.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() UnknownI 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, -
You can't.
Depending on the size of it, you can using a service like pastebin.