From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 71788 invoked by alias); 22 Jan 2018 19:53:09 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 70870 invoked by uid 89); 22 Jan 2018 19:53:08 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=discovery, shooting, spares, Hx-languages-length:2845 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; Mon, 22 Jan 2018 19:53:06 +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 BD3F87485B; Mon, 22 Jan 2018 19:53:05 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id B4CBE1B47F; Mon, 22 Jan 2018 19:52:56 +0000 (UTC) Subject: Re: [PATCH v2] Fix segfault when using 'set print object on' + whatis (Re: [PATCH] Fix segfault when using 'set print object on' + whatis ) To: Sergio Durigan Junior References: <20180116203239.27787-1-sergiodj@redhat.com> <20180120010334.7694-1-sergiodj@redhat.com> <87tvvdbwho.fsf@redhat.com> Cc: GDB Patches , Eli Zaretskii From: Pedro Alves Message-ID: <89e94b33-96dd-474f-cfd6-56125aca7a6d@redhat.com> Date: Mon, 22 Jan 2018 19:53:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <87tvvdbwho.fsf@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2018-01/txt/msg00449.txt.bz2 On 01/22/2018 06:04 PM, Sergio Durigan Junior wrote: > On Monday, January 22 2018, Pedro Alves wrote: > > /me prepares himself for the "this is completely wrong" e-mail > :-) >> On 01/20/2018 01:03 AM, Sergio Durigan Junior wrote: >>> This problem was hidden behind a "maybe-uninitialized" warning >>> generated when compiling GDB with a recent GCC. The warning is: >>> >>> ../../gdb/typeprint.c: In function 'void whatis_exp(const char*, int)': >>> ../../gdb/typeprint.c:515:12: warning: 'val' may be used uninitialized in this function [-Wmaybe-uninitialized] >>> real_type = value_rtti_type (val, &full, &top, &using_enc); >>> ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >>> >>> I submitted a patch fixing this by initializing "val" to NULL, but it >>> was the wrong fix, as Pedro pointed out on >>> : >> >> IMHO, adding such history to the commit log directly doesn't really >> add much here. It's better IMO to leave that to "what changed in v2" >> comments (that don't go in the commit log), and instead update >> the commit log to go straight to the point. (please keep reading.) > > OK. I personally think that it's good to document the actions and > reactions that led me to writing this patch, but this is a small detail. It's good to describe approaches that are seemingly-obvious-but-then-don't-actually-work. That spares the reader/reviewer from going through the same thought process, and/or immediately shooting back with a "why didn't you do it in the other seemingly obvious way" question. In this case, just explaining that the warning is valid obviously switches the previous approach to the "really-obviously-not-correct/incomplete" department, so there's no need to explain it. Commit messages are meant to help future readers understand why changes were made, and being concise and to the point helps. The thing that led to the discovery of the issue is the GCC warning, and that is still mentioned. > Right, I should have added one more test to cover this case as well, > sorry. No worries. This is team work. :-) >> >> As I was writing/experimenting the above, I ended up addressing >> my own comments. What do you think of this patch instead? > > The patch is yours now, so you should be listed as the author, and you > will probably want to rewrite the subject line to make it more correct. > Other than that, and after your e-mail, I don't really have the > expertise to criticize anything. I don't mind either way, but I've pushed the patch in respecting that. And now I realize that this should be needed on the 8.1 branch too. I'll take care of that. Thanks, Pedro Alves