From mboxrd@z Thu Jan 1 00:00:00 1970 From: Fernando Nasser To: Christopher Faylor Cc: Michael Meissner , gdb@sources.redhat.com, Andrew Cagney Subject: Re: alloca is bad? Date: Sun, 12 Nov 2000 00:20:00 -0000 Message-id: <3A0E52BB.750E103A@cygnus.com> References: <20001109212032.A26464@redhat.com> <20001109213750.28987@cse.cygnus.com> <20001109222231.A26675@redhat.com> <3A0DA348.6BDDAFD4@cygnus.com> <20001111191249.A24251@redhat.com> X-SW-Source: 2000-11/msg00103.html 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