Message ID | 20180116203239.27787-1-sergiodj@redhat.com |
---|---|
State | New, archived |
Headers |
Received: (qmail 11637 invoked by alias); 16 Jan 2018 20:32:48 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: <gdb-patches.sourceware.org> List-Unsubscribe: <mailto:gdb-patches-unsubscribe-##L=##H@sourceware.org> List-Subscribe: <mailto:gdb-patches-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-help@sourceware.org>, <http://sourceware.org/ml/#faqs> Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 11498 invoked by uid 89); 16 Jan 2018 20:32:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=technically X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 16 Jan 2018 20:32:46 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1C31DC057FA6; Tue, 16 Jan 2018 20:32:45 +0000 (UTC) Received: from psique.yyz.redhat.com (unused-10-15-17-193.yyz.redhat.com [10.15.17.193]) by smtp.corp.redhat.com (Postfix) with ESMTP id 955DC60C18; Tue, 16 Jan 2018 20:32:41 +0000 (UTC) From: Sergio Durigan Junior <sergiodj@redhat.com> To: GDB Patches <gdb-patches@sourceware.org> Cc: Eli Zaretskii <eliz@gnu.org>, Sergio Durigan Junior <sergiodj@redhat.com> Subject: [PATCH] Fix unitialized warning on gdb/typeprint.c:whatis_exp Date: Tue, 16 Jan 2018 15:32:39 -0500 Message-Id: <20180116203239.27787-1-sergiodj@redhat.com> In-Reply-To: <87po69zkxe.fsf@redhat.com> References: <87po69zkxe.fsf@redhat.com> X-IsSubscribed: yes |
Commit Message
Sergio Durigan Junior
Jan. 16, 2018, 8:32 p.m. UTC
This simple patch initializes "struct value *val" to NULL, which silences a when compiling GDB with certain GCC versions. 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. Is it OK to push this to master and 8.1? I believe I will still need to create a bug with the 8.1 milestone set, even for this simple patch. gdb/ChangeLog: 2017-01-16 Sergio Durigan Junior <sergiodj@redhat.com> * typeprint.c (whatis_exp): Initialize "val" to NULL. --- gdb/typeprint.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Comments
> From: Sergio Durigan Junior <sergiodj@redhat.com> > Cc: Eli Zaretskii <eliz@gnu.org>, > Sergio Durigan Junior <sergiodj@redhat.com> > Date: Tue, 16 Jan 2018 15:32:39 -0500 > > This simple patch initializes "struct value *val" to NULL, which > silences a when compiling GDB with certain GCC versions. > > 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. This fixes the warning for me (of course). Thanks.
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. > 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 ... Thanks, Pedro Alves
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.
diff --git a/gdb/typeprint.c b/gdb/typeprint.c index 9a125076a1..bf9aec5436 100644 --- a/gdb/typeprint.c +++ b/gdb/typeprint.c @@ -405,7 +405,7 @@ error_unknown_type (const char *sym_print_name) static void whatis_exp (const char *exp, int show) { - struct value *val; + struct value *val = NULL; struct cleanup *old_chain; struct type *real_type = NULL; struct type *type;