This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug symtab/22365] New: "info locals" on an unitialized yet vector causes long garbage print


https://sourceware.org/bugzilla/show_bug.cgi?id=22365

            Bug ID: 22365
           Summary: "info locals" on an unitialized yet vector causes long
                    garbage print
           Product: gdb
           Version: 7.11.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: symtab
          Assignee: unassigned at sourceware dot org
          Reporter: n-gcc at nn dot kiev.ua
  Target Milestone: ---

With the code of function shown below, "info locals" causes print of local
variable (namely, std::vector) of uninitialized value. Due to extreme length as
result of garbage, this spoils output and hangs execution.

The function beginning (relevant part) is:

int solution(int N, int A, int B, int C, int D) {
        Point pointF = Point(A, B);
        Point pointS = Point(C, D);

        if (pointS == pointF) {
                return 0;
        }

        int basicMazeSize = int(pow(2, N + 1));
        Maze basicMaze = Maze(Point(0, 0), Point(basicMazeSize,
basicMazeSize));

        vector <OrientedMaze> mazesF;
        mazesF.push_back(OrientedMaze(basicMaze, O_up));
        vector <OrientedMaze> mazesS;
        mazesS.push_back(OrientedMaze(basicMaze, O_up));
[... skip rest ...]

debugger is stopped at breakpoint at the first function line (`Point pointF =
Point(A, B);`);

and, `info locals` emits: (prefix [debug] is from Code::Blocks debugger window)

[debug]> info locals
[debug]pointF = {
[debug]  x = 2, 
[debug]  y = 0
[debug]}
[debug]pointS = {
[debug]  x = 20974602, 
[debug]  y = 0
[debug]}
[debug]basicMazeSize = 32767
[debug]basicMaze = {
[debug]  lowerLeft = {
[debug]    x = -7268, 
[debug]    y = 32767
[debug]  }, 
[debug]  upperRight = {
[debug]    x = -7264, 
[debug]    y = 32767
[debug]  }
[debug]}
[debug]mazesF = std::vector of length 6954038, capacity 6954038 = {{
[debug]    maze = {
[debug]      lowerLeft = {
[debug]        x = 415531848, 
[debug]        y = 254699203
[debug]      }, 
[debug]      upperRight = {
[debug]        x = 33823, 
[debug]        y = 1207959552
[debug]      }
[debug]    }, 
[debug]    orientation = 1208544387
[debug]  }, {
[debug]    maze = {
[debug]      lowerLeft = {

and so on (millions of lines until stopped).

here, not only mazesF is wrong (pointF, pointS are also filled with initial
garbage), but vector length causes its full printing.

Exact gdb version:
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1

(gdb) show configuration
This GDB was configured as follows:
   configure --host=x86_64-linux-gnu --target=x86_64-linux-gnu
             --with-auto-load-dir=$debugdir:$datadir/auto-load
             --with-auto-load-safe-path=$debugdir:$datadir/auto-load
             --with-expat
             --with-gdb-datadir=/usr/share/gdb (relocatable)
             --with-jit-reader-dir=/usr/lib/gdb (relocatable)
             --without-libunwind-ia64
             --with-lzma
             --with-python=/usr (relocatable)
             --without-guile
             --with-separate-debug-dir=/usr/lib/debug (relocatable)
             --with-system-gdbinit=/etc/gdb/gdbinit
             --with-babeltrace

For solution: I don't have a patch, but only an idea that pretty printer shall
take variable initialization status into account, and avoid working on details
in such cases.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]