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. Debugging an application in QtCreator
Forum Update on Monday, May 27th 2025

Debugging an application in QtCreator

Scheduled Pinned Locked Moved Unsolved General and Desktop
12 Posts 8 Posters 4.2k 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.
  • V Offline
    V Offline
    vlada
    wrote on last edited by
    #1

    Hello,

    my application crashes and I can not find the reason why. There is a lot of signals/slots and I can not identify where the problem occurs.

    I tried to debug my application using GDB. Unfortunately the only useful output I got was this:

    ASSERT failure in QList<T>::operator[]: "index out of range", file C:/Qt/5.9.1/mingw53_32/include/QtCore/qlist.h, line 549
    

    I can see I'm calling a list with wrong index. But still didn't help me. I spent many hours trying to find where the incorrect call comes from without any success.

    Is there any way to trace back the call to find out at which line of my code the crash happens? Thank you.

    m.sueM 1 Reply Last reply
    0
    • M Offline
      M Offline
      mchinand
      wrote on last edited by
      #2

      Check out the Debugging section of the QtCreator manual. Debugging in QtCreator should show you where in your code you have this error (it's probably also possible with just gdb and compiled with the proper compiler flags, but I'm not as familiar with it).

      1 Reply Last reply
      0
      • V vlada

        Hello,

        my application crashes and I can not find the reason why. There is a lot of signals/slots and I can not identify where the problem occurs.

        I tried to debug my application using GDB. Unfortunately the only useful output I got was this:

        ASSERT failure in QList<T>::operator[]: "index out of range", file C:/Qt/5.9.1/mingw53_32/include/QtCore/qlist.h, line 549
        

        I can see I'm calling a list with wrong index. But still didn't help me. I spent many hours trying to find where the incorrect call comes from without any success.

        Is there any way to trace back the call to find out at which line of my code the crash happens? Thank you.

        m.sueM Offline
        m.sueM Offline
        m.sue
        wrote on last edited by m.sue
        #3

        Hi @vlada

        you can get a gdb backtrace with the command bt. You will see a list of numbered stack frames. You can change to a specific frame with the f command (e.g. f 23 changes to frame 23). There you can print the code with the l and values of variables with the p <variable name> command.

        You see, as soon as you make it work, it's far easier with a GUI debugger like Qt Creator than GDB.

        -Michael.

        1 Reply Last reply
        0
        • V Offline
          V Offline
          vlada
          wrote on last edited by
          #4

          Hi Michael, this is exactly what I'm looking for. Can I run these commands from QtCreator? Or is it somewhere directly implemented in the GUI and I just don't see it?

          1 Reply Last reply
          0
          • SeenuS Offline
            SeenuS Offline
            Seenu
            wrote on last edited by
            #5

            @vlada

            Hi use CDB debugger it available in
            https://developer.microsoft.com/en-us/windows/hardware/windows-driver-kit
            install and in the code in debugger mode.It will list all Error and warnings where exactly it causing problem

            jsulmJ 1 Reply Last reply
            1
            • SeenuS Seenu

              @vlada

              Hi use CDB debugger it available in
              https://developer.microsoft.com/en-us/windows/hardware/windows-driver-kit
              install and in the code in debugger mode.It will list all Error and warnings where exactly it causing problem

              jsulmJ Online
              jsulmJ Online
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Seenu He is using MinGW, so he cannot use CDB.

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1
              • yuvaramY Offline
                yuvaramY Offline
                yuvaram
                wrote on last edited by
                #7

                Hi @vlada
                If we run in debug mode, when there is a crash, a pointer is showed in tabular column level-function-file-line number.
                According to you if pointer points at Qlist<T > - line 549,
                Memory is not accessible for QList, Check list creation.

                go downward to get exact location.
                I hope this should help you.!!0_1501233988929_crash.PNG

                Yuvaram Aligeti
                Embedded Qt Developer
                : )

                artwawA 1 Reply Last reply
                1
                • Vinod KuntojiV Offline
                  Vinod KuntojiV Offline
                  Vinod Kuntoji
                  wrote on last edited by
                  #8

                  @vlada ,

                  You can use backtrace command and print the variables

                  C++, Qt, Qt Quick Developer,
                  PthinkS, Bangalore

                  1 Reply Last reply
                  1
                  • yuvaramY yuvaram

                    Hi @vlada
                    If we run in debug mode, when there is a crash, a pointer is showed in tabular column level-function-file-line number.
                    According to you if pointer points at Qlist<T > - line 549,
                    Memory is not accessible for QList, Check list creation.

                    go downward to get exact location.
                    I hope this should help you.!!0_1501233988929_crash.PNG

                    artwawA Offline
                    artwawA Offline
                    artwaw
                    wrote on last edited by
                    #9

                    @yuvaram Hi, I think you've got a little misled here.
                    Debugger points you to QList source file, since it's where actual wrong index has been used by the source of it is probably in your code. Index you provided is out of bounds. I would advise putting a breakpoint in your code and then executing subroutine that fails step by step (without getting into build-in routines) to actually see which call fails.

                    For more information please re-read.

                    Kind Regards,
                    Artur

                    yuvaramY 1 Reply Last reply
                    0
                    • artwawA artwaw

                      @yuvaram Hi, I think you've got a little misled here.
                      Debugger points you to QList source file, since it's where actual wrong index has been used by the source of it is probably in your code. Index you provided is out of bounds. I would advise putting a breakpoint in your code and then executing subroutine that fails step by step (without getting into build-in routines) to actually see which call fails.

                      yuvaramY Offline
                      yuvaramY Offline
                      yuvaram
                      wrote on last edited by
                      #10

                      @artwaw
                      Hi ,
                      I agree with you. I gave sample to check logs and trace based on debug output.

                      Yuvaram Aligeti
                      Embedded Qt Developer
                      : )

                      1 Reply Last reply
                      1
                      • V Offline
                        V Offline
                        vlada
                        wrote on last edited by
                        #11

                        Thank you all for the useful information. Unfortunately I still don't understand the steps to get the location in my code where the QList with incorrect index was called.

                        Setting brake points didn't help me. I have a lot functions called by signals emitted by Qt which I can not disable. And I had hard time finding the function which caused the incorrect call. For this particular problem I already found it in the end. I have put some console output to each function end and start to know in which it crashes. Then I found the function and root cause of the problem.

                        But I would like to know the right and quicker solution using DBG in QtCreator.

                        1 Reply Last reply
                        0
                        • yuvaramY Offline
                          yuvaramY Offline
                          yuvaram
                          wrote on last edited by
                          #12

                          debugging can be analyzed without sharing your code.

                          Yuvaram Aligeti
                          Embedded Qt Developer
                          : )

                          1 Reply Last reply
                          1

                          • Login

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