* [patch] Fix for excessive stack use (gdb/10457)
@ 2009-10-08 5:29 Paul Pluzhnikov
2009-10-08 16:20 ` Joel Brobecker
0 siblings, 1 reply; 5+ messages in thread
From: Paul Pluzhnikov @ 2009-10-08 5:29 UTC (permalink / raw)
To: gdb-patches ml; +Cc: Holger Freyther
[-- Attachment #1: Type: text/plain, Size: 261 bytes --]
Greetings,
Calling alloca in a loop is a bad idea.
Here is a fix for gdb/10457; rather on the obvious side.
Thanks,
--
Paul Pluzhnikov
2009-10-07 Paul Pluzhnikov <ppluzhnikov@google.com>
* elfread.c (elf_symtab_read): Don't use alloca in a loop.
[-- Attachment #2: gdb-pr10457-20091007.txt --]
[-- Type: text/plain, Size: 857 bytes --]
Index: elfread.c
===================================================================
RCS file: /cvs/src/src/gdb/elfread.c,v
retrieving revision 1.77
diff -p -u -r1.77 elfread.c
--- elfread.c 30 Apr 2009 21:59:03 -0000 1.77
+++ elfread.c 8 Oct 2009 05:22:49 -0000
@@ -535,7 +535,7 @@ elf_symtab_read (struct objfile *objfile
if (len > 4 && strcmp (sym->name + len - 4, "@plt") == 0)
{
- char *base_name = alloca (len - 4 + 1);
+ char *base_name = xmalloc (len - 4 + 1);
struct minimal_symbol *mtramp;
memcpy (base_name, sym->name, len - 4);
@@ -543,6 +543,7 @@ elf_symtab_read (struct objfile *objfile
mtramp = record_minimal_symbol (base_name, symaddr,
mst_solib_trampoline,
sym->section, objfile);
+ xfree (base_name);
if (mtramp)
{
MSYMBOL_SIZE (mtramp) = MSYMBOL_SIZE (msym);
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch] Fix for excessive stack use (gdb/10457)
2009-10-08 5:29 [patch] Fix for excessive stack use (gdb/10457) Paul Pluzhnikov
@ 2009-10-08 16:20 ` Joel Brobecker
2009-10-08 16:40 ` Paul Pluzhnikov
0 siblings, 1 reply; 5+ messages in thread
From: Joel Brobecker @ 2009-10-08 16:20 UTC (permalink / raw)
To: Paul Pluzhnikov; +Cc: gdb-patches ml, Holger Freyther
> 2009-10-07 Paul Pluzhnikov <ppluzhnikov@google.com>
>
> * elfread.c (elf_symtab_read): Don't use alloca in a loop.
alloca was very convenient because it allows us to not worry about
memory leaks that could happen if record_minimal_symbol throws an error,
for instance. Thanks to Jan's excellent eyes, we know that
record_minimal_symbol eventually results in a call to XCALLOC, which
can possibly cause an internal_error(). It's very unlikely to happen.
So I wouldn't have complained if you had used a cleanup to make sure
that the memory is always released. But in this case, I don't see
record_minimal_symbol ever needing to thrown an exception on its own,
and I don't see that such a small leak can make a difference if we run
out of memory.
The patch is approved.
--
Joel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch] Fix for excessive stack use (gdb/10457)
2009-10-08 16:20 ` Joel Brobecker
@ 2009-10-08 16:40 ` Paul Pluzhnikov
2009-10-08 17:35 ` Joel Brobecker
0 siblings, 1 reply; 5+ messages in thread
From: Paul Pluzhnikov @ 2009-10-08 16:40 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches ml, Holger Freyther
On Thu, Oct 8, 2009 at 9:20 AM, Joel Brobecker <brobecker@adacore.com> wrote:
> The patch is approved.
So committed.
Should I also check this in on the 7.0 branch?
Thanks,
--
Paul Pluzhnikov
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch] Fix for excessive stack use (gdb/10457)
2009-10-08 16:40 ` Paul Pluzhnikov
@ 2009-10-08 17:35 ` Joel Brobecker
2009-10-09 1:42 ` Holger Freyther
0 siblings, 1 reply; 5+ messages in thread
From: Joel Brobecker @ 2009-10-08 17:35 UTC (permalink / raw)
To: Paul Pluzhnikov; +Cc: gdb-patches ml, Holger Freyther
> Should I also check this in on the 7.0 branch?
Sure, the patch looks very safe to me.
--
Joel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch] Fix for excessive stack use (gdb/10457)
2009-10-08 17:35 ` Joel Brobecker
@ 2009-10-09 1:42 ` Holger Freyther
0 siblings, 0 replies; 5+ messages in thread
From: Holger Freyther @ 2009-10-09 1:42 UTC (permalink / raw)
To: Joel Brobecker; +Cc: Paul Pluzhnikov, gdb-patches ml
On Thursday 08 October 2009 19:35:14 Joel Brobecker wrote:
> > Should I also check this in on the 7.0 branch?
>
> Sure, the patch looks very safe to me.
>
Thanks a lot.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-10-09 1:42 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-08 5:29 [patch] Fix for excessive stack use (gdb/10457) Paul Pluzhnikov
2009-10-08 16:20 ` Joel Brobecker
2009-10-08 16:40 ` Paul Pluzhnikov
2009-10-08 17:35 ` Joel Brobecker
2009-10-09 1:42 ` Holger Freyther
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox