This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: alloca is bad?


Christopher Faylor wrote:
> 
> On Sat, Nov 11, 2000 at 07:51:36PM +0000, Fernando Nasser wrote:
> >Someone said that heap corruption was harder to track than stack
> >corruption.
> >
> >I couldn't disagree more.  Many (most?) of the times the function tries
> >to return and gets a buggy return address and frame pointer.
> >It then crashes and you have no idea where it happened.
> 
> Someone, i.e., me, has pointed out that stack overruns happen when you
> use auto arrays

That is true.  Auto arrays are also cause of many stack corruption problems
as well.

But why add more sources?  Because there is evil doesn't justify to add 
MORE evil.

> and pointers to auto variables. 

That is bad programming.

> I don't see how you can
> use this as an argument unless you are advocating that we should only
> use static variables.
> 

I am saying nothing.  The gdb maintainers established this rule quite
some time ago.  I was one that had to back up some code (on one of my
early submissions) to remove calls to alloca (which I use in small programs
that I am the only one to write code to).

But I understood that in a program this size, with about 100+ people adding
code to it you must be EXTRA careful.  Thanks to this rules GDB, despite 
being now a much more sophisticated program, dumps core much less than it
used to do in the past, when the rules were less strict.

I am just defending the established rules here.  They are working and 
IMO they should not be changed unless there are very good reasons
and something close to consensus that they should be changed.



-- 
Fernando Nasser
Red Hat Canada Ltd.                     E-Mail:  fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario   M4P 2C9

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]