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 c++/17685] segmentation fault when trying to print a templated type


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

--- Comment #2 from thomas at loockx dot be ---
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.

-- 
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]