Re: [PATCH] Fixing get_builder() function in dwarf2/read.c

watashiwaher
2020-06-14T17:07:41Z

It is a shame. But it seems I can't. Also I am not so strong in dwarf2.
The binary was so huge and so private, that I was so dumb to understand
what actually inside binary got wrong :(
All I just noticed, it is that get_builder() calls itself recursively, in
such manner:
ptr1 -> ptr2 -> ptr1 -> ptr2 -> ...
And tho I made a small patch that:
1) eliminate recursion
2) uses tortoise algorithm to break out of loop
All I can say, that I really had a halt in this function due to the
recursion, because I debugged that halt in GDB...

On Mon, Jun 15, 2020 at 1:58 AM Simon Marchi <simark@simark.ca> wrote:

> On 2020-06-14 12:49 p.m., watashiwaher via Gdb-patches wrote:
> > Explanation
> > I found that some binaries with debug symbols halt gdb. And the problem
> was
> > in the get_builder() function inside dwarf2/read.c file. The function
> > recursively called itself until infinity. So I tried to fix this issue
> by
> > eliminating recursion and adding the check for cycle detection, and
> > returning nullptr if cycle detected.
> >
> > ChangeLog
> > 2020-06-15 Slava Mitin <watashiwaher@gmail.com>
> >
> > * dwarf2/read.c (get_builder): Added check for cycles
>
> Hi!
>
> Thanks for the patch. We try very hard to have a test case checked in for
> each
> fix like this. Would you be able to share a small reproducer (a small
> program
> that makes GDB crash like this) that we could turn into a test case?
>
> Simon
>