* PATCH to avoid infinite loop in cplus-dem.c on some EDG names
@ 2002-02-15 14:31 scott snyder
2002-02-15 14:36 ` Daniel Jacobowitz
0 siblings, 1 reply; 3+ messages in thread
From: scott snyder @ 2002-02-15 14:31 UTC (permalink / raw)
To: gdb-patches
hi -
The following name, emitted by an EDG-based compiler (kcc 4.0),
causes the demangler to go into an infinite loop when run with
auto demangling. (Try running test-filter with `--format=auto'.)
__CPR212____ct__Q3_3std141list__tm__128_Q2_3edm41THandle__tm__26_Q2_4emid15EMparticleChunkQ2_3std68allocator__tm__51_Q2_3edmJ37J14const_iteratorFRCQ3_3std18list__tm__7_Z1ZZ2Z8iterator
This makes it difficult to use gdb on binaries containing such names ---
gdb hangs while reading in the symbol table.
It's getting stuck in the loop in demangle_arm_hp_template(), where we have:
while (args < e) {
...
switch (*args)
{
...
default:
/* Not handling other HP cfront stuff */
if (!do_type (work, &args, &arg))
goto cfront_template_args_done;
}
...
}
For this case, args is pointing here:
(gdb) p args
$1 = 0x80564c4 "__7_Z1ZZ2Z8iterator"
But do_type doesn't recognize a type of `_' --- and in that case,
it returns without making any progress, leaving its arguments unchanged.
So we loop here forever.
Here's a simple patch to prevent this --- we simply give up if do_type()
doesn't make any progress. We still don't correctly demangle the name,
but at least we don't hang forever.
thanks,
sss
2002-02-15 scott snyder <snyder@fnal.gov>
* testsuite/demangle-expected: Add test case for infinite loop in
demangler.
* cplus-dem.c (demangle_arm_hp_template): Stop trying to demangle
if do_type() doesn't make any progress --- prevents an infinite
loop.
Index: cplus-dem.c
===================================================================
RCS file: /cvs/src/src/libiberty/cplus-dem.c,v
retrieving revision 1.29
diff -u -p -c -r1.29 cplus-dem.c
*** cplus-dem.c 2002/02/05 17:53:17 1.29
--- cplus-dem.c 2002/02/15 22:26:35
*************** demangle_arm_hp_template (work, mangled,
*** 2403,2410 ****
break;
default:
/* Not handling other HP cfront stuff */
! if (!do_type (work, &args, &arg))
! goto cfront_template_args_done;
}
string_appends (declp, &arg);
string_append (declp, ",");
--- 2403,2417 ----
break;
default:
/* Not handling other HP cfront stuff */
! {
! const char* old_args = args;
! if (!do_type (work, &args, &arg))
! goto cfront_template_args_done;
!
! /* Fail if we didn't make any progress: prevent infinite loop. */
! if (args == old_args)
! return;
! }
}
string_appends (declp, &arg);
string_append (declp, ",");
Index: testsuite/demangle-expected
===================================================================
RCS file: /cvs/src/src/libiberty/testsuite/demangle-expected,v
retrieving revision 1.7
diff -u -p -c -r1.7 demangle-expected
*** demangle-expected 2002/01/31 02:21:27 1.7
--- demangle-expected 2002/02/15 22:26:43
*************** _Utf58_0_1__1_2147483647__2147483648
*** 2594,2596 ****
--- 2594,2602 ----
--format=gnu-v3
St9bad_alloc
std::bad_alloc
+ #
+ # This caused an infinite loop.
+ # We still don't demangle this correctly, but at least we don't hang.
+ --format=auto
+ __CPR212____ct__Q3_3std141list__tm__128_Q2_3edm41THandle__tm__26_Q2_4emid15EMparticleChunkQ2_3std68allocator__tm__51_Q2_3edmJ37J14const_iteratorFRCQ3_3std18list__tm__7_Z1ZZ2Z8iterator
+ _Z1ZZ2Z::__CPR212____ct__Q3_3std141list__tm__128_Q2_3edm41THandle__tm__26_Q2_4emid15EMparticleChunkQ2_3std68allocator__tm__51_Q2_3edmJ37J14const_iteratorFRCQ3_3std18list__tm(iterator)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: PATCH to avoid infinite loop in cplus-dem.c on some EDG names
2002-02-15 14:31 PATCH to avoid infinite loop in cplus-dem.c on some EDG names scott snyder
@ 2002-02-15 14:36 ` Daniel Jacobowitz
2002-02-15 15:29 ` Scott Snyder
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Jacobowitz @ 2002-02-15 14:36 UTC (permalink / raw)
To: scott snyder; +Cc: gdb-patches
On Fri, Feb 15, 2002 at 04:31:41PM -0600, scott snyder wrote:
>
> hi -
>
> The following name, emitted by an EDG-based compiler (kcc 4.0),
> causes the demangler to go into an infinite loop when run with
> auto demangling. (Try running test-filter with `--format=auto'.)
Thanks for the patch - but demangler patches need to go to
gcc-patches@gcc.gnu.org. The demangler is maintained outside of GDB.
Are you testing C++ support on this compiler? I'd be quite surprised
if it worked - though not unpleasantly.
--
Daniel Jacobowitz Carnegie Mellon University
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: PATCH to avoid infinite loop in cplus-dem.c on some EDG names
2002-02-15 14:36 ` Daniel Jacobowitz
@ 2002-02-15 15:29 ` Scott Snyder
0 siblings, 0 replies; 3+ messages in thread
From: Scott Snyder @ 2002-02-15 15:29 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches
>>>>> "Daniel" == Daniel Jacobowitz <drow@mvista.com> writes:
Daniel> Thanks for the patch - but demangler patches need to go to
Daniel> gcc-patches@gcc.gnu.org. The demangler is maintained
Daniel> outside of GDB.
Thanks --- i wasn't completely sure where was appropriate. I've sent
another copy there.
Daniel> Are you testing C++ support on this compiler? I'd be
Daniel> quite surprised if it worked - though not unpleasantly.
I've used gcc 4.18 with that compiler for quite a while.
It doesn't really understand the C++ stuff, but it works well enough
to be useful. With gdb 5, though, i started seeing this problem
with gdb sometimes getting stuck reading in EDG symbols.
(Actually, i first reported this in sept. 99 in reference to the SGI C++
compiler; i didn't send a patch at that point though). KAI now has their
own set of patches to gdb 5, but it would be nice to be able to do something
useful with the standard version. (Plus, i saw this problem occur once
even in their patched version.)
thanks,
sss
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-02-15 23:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-15 14:31 PATCH to avoid infinite loop in cplus-dem.c on some EDG names scott snyder
2002-02-15 14:36 ` Daniel Jacobowitz
2002-02-15 15:29 ` Scott Snyder
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox