Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: Simon Marchi <simon.marchi@polymtl.ca>, gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: Re: [PATCH][gdb/symtab] Fix infinite recursion in dwarf2_cu::get_builder()
Date: Wed, 12 May 2021 15:20:54 +0200	[thread overview]
Message-ID: <1c7820ad-4457-b7d4-9828-63daa0f59e5e@suse.de> (raw)
In-Reply-To: <e7d61c37-a61d-c082-3346-75fcece3b2f6@polymtl.ca>

On 5/6/21 5:23 PM, Simon Marchi wrote:
> On 2021-05-06 8:02 a.m., Tom de Vries wrote:
>> Hi,
>>
>> With the test-case attached in PR26327, gdb aborts:
>> ...
>> $ gdb -q -batch 447.dealII -ex "b main"
>> Aborted (core dumped)
>> ...
>> when running out of stack due to infinite recursion:
>> ...
>>  #8  0x00000000006aaba6 in dwarf2_cu::get_builder (this=0x35e4b40)
>>      at src/gdb/dwarf2/read.c:700
>>  #9  0x00000000006aaba6 in dwarf2_cu::get_builder (this=0x22ee2c0)
>>      at src/gdb/dwarf2/read.c:700
>>  #10 0x00000000006aaba6 in dwarf2_cu::get_builder (this=0x35e4b40)
>>      at src/gdb/dwarf2/read.c:700
>>  #11 0x00000000006aaba6 in dwarf2_cu::get_builder (this=0x22ee2c0)
>>      at src/gdb/dwarf2/read.c:700
>> ...
>>
>> We're recursing in this code in dwarf2_cu::get_builder():
>> ...
>>      /* Otherwise, search ancestors for a valid builder.  */
>>      if (ancestor != nullptr)
>>        return ancestor->get_builder ();
>> ...
>> due to the fact that the ancestor chain is a cycle.
>>
>> Higher up in the call stack, we find some code that is responsible for
>> triggering this, in new_symbol:
>> ...
>>        case DW_TAG_formal_parameter:
>>          {
>>            /* If we are inside a function, mark this as an argument.  If
>>               not, we might be looking at an argument to an inlined function
>>               when we do not have enough information to show inlined frames;
>>               pretend it's a local variable in that case so that the user can
>>               still see it.  */
>>            struct context_stack *curr
>>              = cu->get_builder ()->get_current_context_stack ();
>>            if (curr != nullptr && curr->name != nullptr)
>>              SYMBOL_IS_ARGUMENT (sym) = 1;
>> ...
>>
>> This is code that was added to support pre-4.1 gcc, to be able to show
>> arguments of inlined functions as locals, in the absense of sufficiently
>> correct debug information.
>>
>> Removing this code (that is, doing SYMBOL_IS_ARGUMENT (sym) = 1
>> unconditially), fixes the crash.  The ancestor variable also seems to have
>> been added specifically to deal with fallout from this code, so remove that as
>> well.
>>
>> Tested on x86_64-linux:
>> - openSUSE Leap 15.2 with gcc 7.5.0, and
>> - openSUSE Tumbleweed with gcc 10.3.0.
>>
>> Any comments?
> 
> I did not study the problem in depth like you did, but based on your
> explanation I think this is reasonable.  If support for ancient stuff
> gets in the way of supporting modern stuff (like LTO), then it makes
> sense to remove the support for the ancient stuff.

I committed this, but now realized that the cases I was actually trying
to fix: gcc-10 -flto code, aren't fixed, they just changed failure mode
from hang to abort.

So it looks like I did a point fix which just fixes the 447.dealII
test-case, not the generic case.

I may revert this patch (although atm I don't see the immediate need,
given that all the examples I looked at sofar also were problematic
before this patch).

Thanks,
- Tom

  reply	other threads:[~2021-05-12 13:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-06 12:02 Tom de Vries
2021-05-06 15:16 ` Eli Zaretskii via Gdb-patches
2021-05-06 15:24   ` Tom de Vries
2021-05-06 15:42     ` Eli Zaretskii via Gdb-patches
2021-05-06 15:23 ` Simon Marchi via Gdb-patches
2021-05-12 13:20   ` Tom de Vries [this message]
2021-05-12 13:55     ` Tom de Vries

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=1c7820ad-4457-b7d4-9828-63daa0f59e5e@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@polymtl.ca \
    --cc=tom@tromey.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