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 v2] Fix segfault when using 'set print object on' + whatis <struct> (Re: [PATCH] Fix segfault when using 'set print object on' + whatis <struct>)


On Monday, January 22 2018, Pedro Alves wrote:

>>> 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
>>>> <https://sourceware.org/ml/gdb-patches/2018-01/msg00346.html>:
>>>
>>> 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.

I understand your point.  To the experienced reader, the final commit
message (written by you) is indeed better because it removes the
previous attempt I made to fix this issue by just initializing VAL to
NULL.  Since I was the one who made the mistake of not fully
understanding the consequences of the warning, I thought it made sense
to explain everything, from the very beginning, when I thought this was
just a silly warning) to the point where you pointed me to the real bug.
While this commit message made sense to me, and can probably be
considered "too much" for the experienced reader, I still think it would
be a nice addition.  But I don't want to create a confusion/mess/issue
out of this specific part, so I'm totally fine with your final message.

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

Yes, thanks for doing, I was going to send a message reminding you about
the 8.1 branch.

Thanks,

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