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?


Chris Faylor wrote:

> I've debugged many cases of stack corruption over my disgustingly long
> career as a programmer.  I can't remember a specific case that troubled
> me for very long.  I can remember, at least two cases where I spent days
> trying to track down heap corruption problems, however.

As they say, our energy efficency units have varied.

> Nick Duffek has requested that the procedures for determining
> programming guidelines in GDB be clarified.  The feeling that I get from
> Andrew and Fernando is that this alloca discussion has raged on before
> and that the issue had been decided time ago.  I've checked the mailing
> list archives and I don't see any definitive statements about this
> subject, however.  If there is a document that says "Don't Use alloca
> and Here's Why" no one has pointed it out yet.

Largely maintainer wim and folk law.

To re-iterate earlyer points.  The official problem with alloca() is
that it is very non-portable.  You can be pretty sure problems with this
date back to when GDB was first written and, consequently, the exact
details are now well and truely lost in time.

The BSD man page has:

  BUGS
     The alloca() function is machine dependent; its use is discouraged.

the Solaris man page has:
  WARNINGS
     ....

     alloca() is machine-, compiler-, and most  of  all,  system-
     dependent.  Its use is strongly discouraged.

With regard to multi-arch, the decision to allow alloca() was strictly
pragmatic - using it was far less error proned then trying to convert
all dynamic arrays to cleanups.  Part of the pragmatism behind it was
that it was thought that all the systems that had broken alloca()
implementations had long-ago been switched off.

> Since at least four GDB maintainers have expressed their desire to
> use alloca, is that an adequate quorom?  What's the procedure here?  Are
> we eventually going to come to a decision and document it?  Or, are we
> going to keep wrangling until someone gets tired?

See the threads originating from:

http://sources.redhat.com/ml/gdb/2000-11/msg00085.html

	Andrew

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