This is the mail archive of the gdb-patches@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]

Re: [PATCH] Fix unitialized warning on gdb/typeprint.c:whatis_exp


On Wednesday, January 17 2018, Pedro Alves wrote:

> On 01/16/2018 08:32 PM, Sergio Durigan Junior wrote:
>> This simple patch initializes "struct value *val" to NULL, which
>> silences a when compiling GDB with certain GCC versions.
>
> Please include a representative paste of warnings in git logs.
> It makes it easier to see what a patch/commit is about.

Will do.

>> This warning is technically incorrect, because there is now way that
>> "val" will be used unitialized if you look at the code flow, but it's
>> a simple "fix" and doesn't do any harm.
>
> No, it's not incorrect.  It's showing a real bug.  Try, e.g.:
>
> (gdb) set print object on
> (gdb) whatis some_structure_type
>
> Thread 1 "gdb" received signal SIGSEGV, Segmentation fault.
> 0x00000000005dda90 in check_typedef (type=0x6120736573756170) at src/gdb/gdbtypes.c:2388
> 2388      int instance_flags = TYPE_INSTANCE_FLAGS (type);
> (top-gdb) bt
> #0  0x00000000005dda90 in check_typedef(type*) (type=0x6120736573756170) at src/gdb/gdbtypes.c:2388
> #1 0x00000000005e63fb in gnuv3_rtti_type(value*, int*, LONGEST*, int*)
> (value=0xdf21b7, full_p=0x7fffffffd180, top_p=0x7fffffffd188,
> using_enc_p=0x7fffffffd184) at src/gdb/gnu-v3-abi.c:293
> #2  0x000000000055f7d8 in value_rtti_type(value*, int*, long*, int*) (v=0xdf21b7, full=0x7fffffffd180, top=0x7fffffffd188, using_enc=0x7fffffffd184) at src/gdb/cp-abi.c:117
> #3  0x00000000006cc61f in whatis_exp(char const*, int) (exp=<optimized out>, show=-1) at src/gdb/typeprint.c:515
> #4  0x0000000000472462 in cmd_func(cmd_list_element*, char const*, int) (cmd=<optimized out>, args=<optimized out>, from_tty=<optimized out>)
>     at src/gdb/cli/cli-decode.c:1886
> #5  0x00000000006b833a in execute_command(char const*, int) (p=<optimized out>, from_tty=1) at src/gdb/top.c:630
> #6  0x00000000005c0f8c in command_handler(char const*) (command=0xdf21b0 "whatis siginfo_t") at src/gdb/event-top.c:583
> #7  0x00000000005c12d8 in command_line_handler(char*) (rl=<optimized out>) at /home/pedro/gdb/mygit/src/gdb/event-top.c:774
> ...

Ah, I totally missed that.  Sorry about jumping into the conclusion that
it was incorrect.

I'll try to investigate what's happening here.

-- 
Sergio
GPG key ID: 237A 54B1 0287 28BF 00EF  31F4 D0EB 7628 65FC 5E36
Please send encrypted e-mail if possible
http://sergiodj.net/


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