Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [read_frame_arg patch] Handle partially optimized out values similarly to unavailable values (Re: [patchv2] Fix crash on optimized-out entry data values)
Date: Tue, 22 Jul 2014 19:33:00 -0000	[thread overview]
Message-ID: <53CEB93A.4020709@redhat.com> (raw)
In-Reply-To: <20140720150727.GA18488@host2.jankratochvil.net>

On 07/20/2014 04:07 PM, Jan Kratochvil wrote:
> On Thu, 17 Jul 2014 14:23:06 +0200, Pedro Alves wrote:
>> On 07/16/2014 10:58 PM, Jan Kratochvil wrote:
>>> This patch is apparently not suitable for gdb-7.8 which is I guess often
>>> crashing on -O2 -g entry values so there could be some rather minimal crash
>>> avoiding patch instead.
>>
>> Yeah.
>>
>> So this was originally "caused" (more exposed) by 4f14910f:
>>     
>>         gdb/ChangeLog
>>         2013-11-26  Andrew Burgess  <aburgess@broadcom.com>
>>     
>>             * value.c (allocate_optimized_out_value): Mark value as non-lazy.
>>
>> I tried a few approaches in value_available_contents_eq
>> today, and ended up thinking that the simplest should be to
>> just revert that patch until we have the fuller fix in place.
> 
> OK, that seems as the best solution for 7.8 to me.
> 
> 
>> While doing just that fixes the crash, it surprisingly causes
>> one of your new tests to FAIL:
>>
>>  (gdb) frame
>>  #0  bar (ref=ref@entry=@0x7fffffffd184: 10) at gdb.arch/amd64-entry-value-paramref.cc:23
>>  23        vv++; /* break-here */
>>  (gdb) FAIL: gdb.arch/amd64-entry-value-paramref.exp: frame
> 
> There is a bug in that entry value code of mine, fix attached.
> The testcase then PASSes with the reverted optimization by Andrew Burgess.
> 

OK, I've pushed the reversion (without the #if 0 bit) to both master
and 7.8.

> For the attached fix - if you nitpick the missing conditional case:
> 	value_optimized_out (val_deref) && value_optimized_out (entryval_deref)
> It is not detected there but that IMO does not matter much as
>  * It is for 7.8 only, for trunk it will get compared correctly thanks to the
>    new implementation of value_available_contents_eq()
>    called value_contents_eq().
>  * If the conditional
>                       if (val != val_deref
>                           && !value_optimized_out (val_deref)
>                           && !value_optimized_out (entryval_deref)
>                           && value_available_contents_eq (val_deref, 0,
>                                                           entryval_deref, 0,
>                                                       TYPE_LENGTH (type_deref)))
>                         val_equal = 1;
>    fails it may just print
>      bar (ref=@0x7fffffffd904: <optimized out>, ref@entry=@0x7fffffffd904: <optimized out>)
>    (or some variant with some partially optimized-out/unavailable parts)
>    instead of the more correct
>      bar (ref=ref@entry=@0x7fffffffd904: <optimized out>)
>    which is not much a bug.

That's fine with me.

> The attached fix no longe makes sense after the new implementation
> of value_available_contents_eq() called value_contents_eq() gets applied as it
> handles all the optimized-out/unavailable values on its own, therefore the
> attached patch is really only for 7.8.

As it's best not to get ourselves in a situation where we have a fix in
the branch but not in mainline, and avoid putting pressure on the
better fix, it's better to put your patch in mainline too.

> I do not see how to access
> 	((struct value *)arg1.location.computed.closure).location.address
> from GDB CLI.  Trying
> (gdb) p &ref@entry
> will invoke value_addr()'s:
>   if (TYPE_CODE (type) == TYPE_CODE_REF)
>       /* Copy the value, but change the type from (T&) to (T*).  We
>          keep the same location information, which is efficient, and
>          allows &(&X) to get the location containing the reference.  */
> and therefore the address gets fetched already from
>   arg1.contents
> and not from
>   ((struct value *)arg1.location.computed.closure).location.address
> .
> 

Yeah.

> And for any other type than TYPE_CODE_REF this code you #if 0-ed does not get
> executed at all.  This DW_AT_GNU_call_site_data_value DWARF was meant
> primarily for Fortran but with -O0 entry values do not get produced
> and with -Og and higher Fortran always optimizes out the passing by reference.
> 
> If you do not like the #if 0 code there I am OK with removing it as I do not
> know how to make it's use reproducible for user anyway.  In the worst case
> - if there really is some way how to exploit it - one should just get
>   Attempt to take address of value not located in memory.
> instead of some wrong value and it may be easy to fix then.

Thanks Jan.  Indeed I'd much prefer removing it.
It's fine with me to still leave it in 7.8 in case we missed
something.

-- 
Pedro Alves


  reply	other threads:[~2014-07-22 19:19 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-09 10:33 [patchv2] Fix crash on optimized-out entry data values Jan Kratochvil
2014-07-09 11:52 ` Pedro Alves
2014-07-09 15:31   ` Jan Kratochvil
2014-07-11 16:07     ` [patchv3] " Jan Kratochvil
2014-07-14  7:02       ` Yao Qi
2014-07-14  8:32         ` Jan Kratochvil
2014-07-14 18:12       ` Pedro Alves
2014-07-14 18:47     ` [PATCH] Handle partially optimized out values similarly to unavailable values (Re: [patchv2] Fix crash on optimized-out entry data values) Pedro Alves
2014-07-17  8:04       ` Jan Kratochvil
2014-07-17  8:35         ` Jan Kratochvil
2014-07-17 13:38         ` Pedro Alves
2014-07-20 15:33           ` [read_frame_arg patch] " Jan Kratochvil
2014-07-22 19:33             ` Pedro Alves [this message]
2014-07-22 20:21               ` [commit+7.8] [read_frame_arg patch] Handle partially optimized out values similarly to unavailable values Jan Kratochvil
2014-08-05 17:16                 ` Doug Evans
2014-08-14 18:25                   ` Jan Kratochvil
2014-07-23 14:26               ` [commit] Remove setting value address for reference entry value target data value Jan Kratochvil
2014-07-24 12:51         ` [PATCH v2] Handle partially optimized out values similarly to unavailable values Pedro Alves
2014-08-15 20:13           ` Jan Kratochvil
2014-08-19 23:36             ` Pedro Alves
2014-08-20  0:55               ` Andrew Pinski
2014-08-20  9:46                 ` Pedro Alves
2014-08-20 10:32                   ` [PUSHED] value.c (value_contents_bits_eq): Initialize l,h for gcc, -Wall. (was: Re: [PATCH v2] Handle partially optimized out values similarly to unavailable values) Pedro Alves
2014-08-20 16:28                     ` Andrew Pinski
2014-08-21 19:57               ` Regression for i686 gdb.dwarf2/pieces-optimized-out.exp [Re: [PATCH v2] Handle partially optimized out values similarly to unavailable values] Jan Kratochvil
2014-08-22 16:20                 ` Pedro Alves
2014-08-24 19:56                   ` Jan Kratochvil
2014-09-04 11:36                   ` [pushed] " Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53CEB93A.4020709@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox