Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-20476

Can't debug STL-containers when using _GLIBCXX_DEBUG.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3: Somewhat important
    • Qt Creator 15.0.0-beta1
    • Qt Creator 4.6.1
    • Debugger
    • fca70aa95 (15.0)

    Description

      {{
      Can't debug standard containers when using _GLIBCXX_DEBUG.

      Tested with: Qt-Creator 4.6.1, gcc 8.0.1, gdb 7.7.1

      Short example:
      ============
      #include <vector>
      #include <iostream>

      int main(int,char**) {
      std::vector<int> nums =

      {1,2,3,4,5,6,7,8,9,10}

      ;

      // read past the end:
      for(unsigned int i=0;i<=10;++i)
      std::cout << nums[i] << " ";
      std::cout << std::endl;
      return 0; // breakpoint here
      }
      ============
      Prints (happily reads past the end):
      1 2 3 4 5 6 7 8 9 10 132033

      Debugging – locals window (correct):
      Name | Value | Type
      ========================
      nums | <10 items> | std::vector<int>
      ... the 10 values listed correctly.

      ---------------------------------------------------------------------------------
      With

      DEFINES += _GLIBCXX_DEBUG

      in .pro file (Rebuild All !!!), this will print the following errors:

      ====
      The inferior stopped because it received a signal from the operating system.

      Signal name :
      SIGABRT
      Signal meaning :
      Aborted

      /usr/include/c++/8/debug/vector:417:
      Error: attempt to subscript container with out-of-bounds index 10, but
      container only holds 10 elements.

      Objects involved in the operation:
      sequence "this" @ 0x0x7ffd63d89800

      { type = std::__debug::vector<int, std::allocator<int> >; }

      1 2 3 4 5 6 7 8 9 10
      ====

      However, when debugging (breakpoint before the loop):
      Name | Value | Type
      ========================
      nums | <0 items> | std::vector<int>
      (Internal Type: std::__debug::vector<int,std::allocator<int> >

      Debugging of STL-containers now isn't possible anymore.

      _GLIBCXX_DEBUG enables checks for invalid iterators, use-after-free, deadlocks (std locks only, obviously) and much more. It uses specific 'debug containers' for doing so. When debugging, it is usually preferable to turn this on.
      I believe this bug had already been fixed in the past (Qt-Creator 2-somthing)...
      }}

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              ansemkiv Andrii Semkiv
              _lc_ Ninel Evol
              Votes:
              3 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes