Created attachment 8001 [details] test file to reproduce the segmentation fault Attached is an example program. Set a breakpoint in main and try to print out test (p test). gdb will segfault. I cleared my .gdbinit file so no weird settings.
(In reply to thomas from comment #0) > Attached is an example program. Set a breakpoint in main and try to print > out test (p test). gdb will segfault. I've tried this on 7.8/HEAD here, and it works. However, there are a number of possible issues that could be causing your problems. Are you using python STL pretty-printers? Are they up to date? The next thing to try is printing after the vector is initialized. If memory serves, uninitialized STL containers sometimes cause problems for the pretty-printers. Please add, e.g., a (cough, missing) "return 0;" at the end of main. Stop on this line and try to print the vector again. What's the result? Please fill in the host and target bugzilla fields (or provide output of "show version" in a comment), that would help also narrow the focus of further investigations. Finally, if possible, please provide a stack backtrace of the segfault, it would undoubtedly prove most enlightening.
Here's a less sloppy report. GDB version used to reproduces the crash (downloaded and build from the website): thomas@thomas-work-pc:~/Downloads/gdb-7.8.1/gdb$ ./gdb --version GNU gdb (GDB) 7.8.1 Copyright (C) 2014 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-unknown-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word". Here's a backtrace I captured by running the compiled gdb in the gdb on my system (GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1): Breakpoint 1, main (argc=1, argv=0x7fffffffde58) at gdb-crash.cpp:16 16 return 0; (gdb) p test Program received signal SIGSEGV, Segmentation fault. 0x00000000004f59c6 in value_entirely_optimized_out (value=0x0) at value.c:1261 1261 if (!value->optimized_out) (gdb) bt #0 0x00000000004f59c6 in value_entirely_optimized_out (value=0x0) at value.c:1261 #1 0x000000000060a1fe in cp_print_static_field (options=<optimized out>, recurse=<optimized out>, stream=<optimized out>, val=<optimized out>, type=0x0) at cp-valprint.c:643 #2 cp_print_value_fields (type=<optimized out>, real_type=<optimized out>, valaddr=<optimized out>, offset=<optimized out>, address=<optimized out>, stream=<optimized out>, recurse=0, val=0xdd0000, options=0x7fffffffd830, dont_print_vb=0x0, dont_print_statmem=0) at cp-valprint.c:336 #3 0x000000000060a7e2 in cp_print_value_fields_rtti (type=0xc57480, valaddr=0xd13a00 "", offset=0, address=140737488346464, stream=<optimized out>, recurse=0, val=0xdd0000, options=0x7fffffffd830, dont_print_vb=0x0, dont_print_statmem=0) at cp-valprint.c:456 #4 0x0000000000608cf7 in c_val_print (type=0xc57480, valaddr=<optimized out>, embedded_offset=0, address=<optimized out>, stream=0xc40cc0, recurse=<optimized out>, original_value=0xdd0000, options=0x7fffffffd830) at c-valprint.c:394 #5 0x000000000050e66b in val_print (type=<optimized out>, valaddr=<optimized out>, embedded_offset=<optimized out>, address=<optimized out>, stream=<optimized out>, recurse=<optimized out>, val=0xdd0000, options=0x7fffffffd8e0, language=0x7b1040 <cplus_language_defn>) at valprint.c:790 #6 0x0000000000608870 in c_value_print (val=0xdd0000, stream=0xc40cc0, options=<optimized out>) at c-valprint.c:585 #7 0x000000000051208e in print_command_1 (exp=0xb63192 "test", voidprint=<optimized out>) at ./printcmd.c:997 #8 0x0000000000617dc0 in execute_command (p=0xb63190 "p test", from_tty=1) at top.c:479 #9 0x00000000005573f5 in command_handler (command=0xb63190 "p test") at event-top.c:484 #10 0x0000000000557ffc in command_line_handler (rl=<optimized out>) at event-top.c:681 #11 0x0000000000664feb in rl_callback_read_char () at callback.c:220 #12 0x0000000000557469 in rl_callback_read_char_wrapper (client_data=0x0) at event-top.c:167 #13 0x0000000000556264 in process_event () at event-loop.c:343 #14 0x00000000005571f4 in gdb_do_one_event () at event-loop.c:407 #15 0x0000000000557255 in start_event_loop () at event-loop.c:432 #16 0x000000000054fe93 in captured_command_loop (data=0x0) at main.c:303 #17 0x000000000054cb4b in catch_errors (func=<optimized out>, func_args=<optimized out>, errstring=<optimized out>, mask=<optimized out>) at exceptions.c:506 #18 0x0000000000550bc6 in captured_main (data=<optimized out>) at main.c:1164 #19 0x000000000054cb4b in catch_errors (func=<optimized out>, func_args=<optimized out>, errstring=<optimized out>, mask=<optimized out>) at exceptions.c:506 #20 0x000000000054fcfb in gdb_main (args=0xffffffff) at main.c:1172 #21 0x0000000000406d65 in main (argc=<optimized out>, argv=0xffffffff) at gdb.c:33 (gdb) Looks to me that value is a NULL ptr. I've attached the updated test program with a proper return statement.
Created attachment 8012 [details] updated test file
Created attachment 8013 [details] full gdb session
This problem can be reproduced if built with older g++ such as 4.4.7, which emitted a DWARF declaration DIE for the static data member: <1><f4>: Abbrev Number: 14 (DW_TAG_variable) <f5> DW_AT_name : (indirect string, offset: 0x5c): DIMS <f9> DW_AT_decl_file : 1 <fa> DW_AT_decl_line : 4 <fb> DW_AT_MIPS_linkage_name: (indirect string, offset: 0x47): _ZN7Vector2IfE4DIMSE <ff> DW_AT_type : <0x66> <103> DW_AT_external : 1 <104> DW_AT_declaration : 1 When attempting to print its value, default_read_var_value() failed and threw an exception because the symbol existed in the debug info but not in the minsym table. The exception was not caught in value_static_field() and led to the segfault. The problem disappears with newer g++, e.g. 4.8.5, which stops emitting such debug info entry.
If you can build the test executable and attach it, that would be helpful.
Created attachment 11255 [details] test case that crashes gdb
*** Bug 20607 has been marked as a duplicate of this bug. ***
I'm going to mark this one as the dup since 20020 has more info. However I'll leave a note there pointing back at the test executable that is here. *** This bug has been marked as a duplicate of bug 20020 ***