[SOLVED] Crash error when deleting a QList< QPair<QString, QString> >
-
Hi,
I'm using Qt 4.8 and the library "O2":https://github.com/pipacs/o2 and I'm facing a crash issue when deleting a QList< QPair<QString, QString> >. The problem is not related to O2 library and I was able to locate which lines cause the crash. Here is the code:
@QUrl getTokenUrl("http://localhost?hello=world");
QList< QPair<QString, QString> > tokens = getTokenUrl.queryItems();
tokens.clear();@But, lines below will not crash (why?):
@QList< QPair<QString, QString> > tokens;
tokens.append(qMakePair<QString, QString>(QUrl::fromPercentEncoding(QByteArray("hello")), QUrl::fromPercentEncoding("world")));
tokens.clear();@I looked in a lot of directions and I don't understand where is the problem.
Any suggestions are welcomed.Regards,
Jonathan -
Hi and welcome to devnet,
Just to rule out the obvious: are you sure the crash happen when clearing tokens ?
Did you run your application through with the debugger ?
-
Hi,
Thank you for your reply.
Yes, I'm using Visual Studio 2010 debugger and Yes, crash occurs when tokens are cleared (or when variable is deleted).
-
I add that I am running Windows 7 64 bit with a "standard" build of Qt 4.8.5 (just --Zc:wchar_t-- removed from QMAKE_CFLAGS). Maybe problem comes from that?
-
In that case, are you sure that getTokenUrl.queryItems() returns something that is correct ?
-
Then you need to also check whether any other library you are linking to does follow that
-
Here is my debugger output:
!http://s18.postimg.org/7pyw0reix/qt_bug_qlist.png(debugger output)!
And stack trace after crash occurs:
!http://s15.postimg.org/5u3a6oq2j/qt_bug_stack.png(stack trace)!
-
Did you check that all the libraries you are using are compiled with the same wchart_t options ?
-
I checked multiple times and everything seems ok. My project isn't "young" and it's the first time I encounter this problem. I don't know which way to look...
(I don't remember I have crash on Qt 4.8.0, but I need to confirm). -
Which version of Qt are you using now ? There has been a change in the wchart_t flag, in Qt 5 it's the opposite of what was used for Qt 4
-
I've found the problem by creating a new project and copying the parameters one by one.
The code below crash if I use the Runtime Library option Multi-threaded DLL (/MD) in debug mode (Qt 4.8.5, Visual Studio 2010 with platform toolset v90, 64 bit).
@int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);QUrl getTokenUrl(QString::fromLatin1("http://localhost?hello=world"));
QList< QPair<QString, QString> > tokens = getTokenUrl.queryItems();
tokens.clear();return a.exec();
}@This option is needed by my target environment but I'll see if I can do without.
Maybe you have a suggestion?
-
It seems it will be impossible for me to change this project settings. So I think I need to rebuild my Qt libraries with the option QMAKE_CFLAGS_DEBUG = -Zi -MD in the qmake.conf (for win32-msvc2008).
Thank you for your patience.
Regards -
Aren't you using 2010 ?
Which project settings can't you changed ?
-
I'm using Visual Studio 2010 with platform toolset v90 (VS2008) and v100 (VS2010), because I target multiple environement.
I can't change the project settings Runtime Library, it must be set on Multi-threaded DLL (/MD) (in debug/release mode).
-
Did you succeeded ?
-
Yes. I rebuild Qt for (v90 - v100 / 32 and 64 bit) with MD flag for Debug and everything is ok. I forgot I had a similar problem with QPrinterInfo::availablePrinters(), and it fix this issue too.
Thank you for your help.
Regards.