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. [SOLVED] Crash error when deleting a QList< QPair<QString, QString> >
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Crash error when deleting a QList< QPair<QString, QString> >

Scheduled Pinned Locked Moved General and Desktop
16 Posts 2 Posters 6.8k Views 1 Watching
  • 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.
  • M Offline
    M Offline
    maisoui
    wrote on last edited by
    #1

    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

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

      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 ?

      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
      • M Offline
        M Offline
        maisoui
        wrote on last edited by
        #3

        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).

        1 Reply Last reply
        0
        • M Offline
          M Offline
          maisoui
          wrote on last edited by
          #4

          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?

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

            In that case, are you sure that getTokenUrl.queryItems() returns something that is correct ?

            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
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Then you need to also check whether any other library you are linking to does follow that

              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
              • M Offline
                M Offline
                maisoui
                wrote on last edited by
                #7

                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)!

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

                  Did you check that all the libraries you are using are compiled with the same wchart_t options ?

                  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
                  • M Offline
                    M Offline
                    maisoui
                    wrote on last edited by
                    #9

                    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).

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

                      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

                      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
                      • M Offline
                        M Offline
                        maisoui
                        wrote on last edited by
                        #11

                        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?

                        1 Reply Last reply
                        0
                        • M Offline
                          M Offline
                          maisoui
                          wrote on last edited by
                          #12

                          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

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

                            Aren't you using 2010 ?

                            Which project settings can't you changed ?

                            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
                            • M Offline
                              M Offline
                              maisoui
                              wrote on last edited by
                              #14

                              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).

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

                                Did you succeeded ?

                                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
                                • M Offline
                                  M Offline
                                  maisoui
                                  wrote on last edited by
                                  #16

                                  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.

                                  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