Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gdb freezes using cmd -var-list-children on unitialized std::vector #40

Open
AHeimberger opened this issue Nov 25, 2012 · 1 comment
Open

Comments

@AHeimberger
Copy link

gdb/mi freezes with pretty/printers enabled when a user access a not initialized vector. gdb/mi not directly freezes, but walks through all the memory it can access, as long as is doesn't access a not exisiting memory (segsev). for the user gdb/mi looks frozen because the size of the vector can be of different sizes (YMMS). This errors comes from calculating the size of the std::vector, which is calculated from vec._M_impl._M_finish - vec._M_impl._M_start. Size of the vector is not calculable, when the vector is not initialized.

Reported-Bug : http://sourceware.org/bugzilla/show_bug.cgi?id=14373

This issue gives an impression of this known but not avoidable bug under current versions:

  • Linux version 3.2.0-23-generic (buildd@crested)
  • GNU gdb (Ubuntu/Linaro 7.4-2012.02-0ubuntu2) 7.4-2012.02
  • gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)
Install Pretty Printers:
  1. Download STL-Pretty-Printer http://sourceware.org/gdb/wiki/STLSupport
  2. Create a .gdbinit file, explained at http://sourceware.org/gdb/wiki/STLSupport
Create a Testprogram called main.cpp:
#include <vector>

int main() {
    std::vector<int> vec;

    vec.push_back(1);
    vec.push_back(1);
    vec.push_back(1);
    vec.push_back(1);
    vec.push_back(1);
    vec.push_back(1);
    vec.push_back(1);

    return 0;
}
Create the Objectfile:

g++ -g main.cpp -o main.o

Start GDB/MI:

gdb -i mi main.o

Execute following CMD's and GDB-Freezes:

-enable-pretty-printing
-break-insert main
-exec-run
-stack-list-variables --all-values
-var-create - * vec
-var-list-children var1

Execute following CMD's and GDB doesn't freeze but shows non existing values:

-enable-pretty-printing
-break-insert main
-exec-run
-stack-list-variables --all-values
-var-create - * vec
-var-list-children var1 0 10
^done,numchild="10",displayhint="array",children=[child={name="var2.[0]",exp="[0]",numchild="0",type="int",thread-id="1"},child={name="var2.[1]",exp="[1]",numchild="0",type="int",thread-id="1"},child={name="var2.[2]",exp="[2]",numchild="0",type="int",thread-id="1"},child={name="var2.[3]",exp="[3]",numchild="0",type="int",thread-id="1"},child={name="var2.[4]",exp="[4]",numchild="0",type="int",thread-id="1"},child={name="var2.[5]",exp="[5]",numchild="0",type="int",thread-id="1"},child={name="var2.[6]",exp="[6]",numchild="0",type="int",thread-id="1"},child={name="var2.[7]",exp="[7]",numchild="0",type="int",thread-id="1"},child={name="var2.[8]",exp="[8]",numchild="0",type="int",thread-id="1"},child={name="var2.[9]",exp="[9]",numchild="0",type="int",thread-id="1"}],has_more="1"

Further CMD's

Use these commands to evaluate that your pretty-printers are really enabled or disabled.
disable pretty-printer
enable pretty-printer

@rainerf
Copy link
Owner

rainerf commented Nov 28, 2012

Thanks for this thorough report. We'll consider this solution in the implementation, I'm leaving this report open in the meantime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants