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?


On Sat, Nov 11, 2000 at 05:06:19PM +1100, Andrew Cagney wrote:
> 	o	the suggestion that some platforms
> 		don't support even libiberty's alloca.
> 
> 		I'd be very interested in knowing the
> 		details of this.

Some (non-mainstream) systems allocate their stack in chunks from the heap.
When the stack is exhausted for the current chunk, they allocate some more
memory for the next chunk.  This doesn't work because the libiberty version of
alloca depends on the allocations being monotonically increasing or
decreasing.  When I was in the original X3J11 meetings, I remember this coming
up, and the original Crays used this allocation technique and possibly some of
the mainframe systems.

I've also heard of systems which use languages like Simula 67 that have
coroutines in them, each stack frame is allocated, and points back to the
parent frame.  Due to threading, there may be multiple pointers back to the
parent frame, and stack frames are garbage collected like everything else.
This is the so-called cactus stack that I mentioned.

Also in the original meetings, when I proposed alloca (and got shot down
basically 1 to everybody), Harris among others mentioned there was no way they
could ever have a variable sized stack.  Given C99 now has variable length
arrays, I dunno whether they planned to allocate VLAs or what.

Now, when RMS decided that alloca was a useful feature for the GNU system, he
knew it might be restricting which systems it could  be ported to.  Most
systems these days can support alloca in some form or another, but being
pedantic, most != all.

-- 
Michael Meissner, Red Hat, Inc.
PMB 198, 174 Littleton Road #3, Westford, Massachusetts 01886, USA
Work:	  meissner@redhat.com		phone: +1 978-486-9304
Non-work: meissner@spectacle-pond.org	fax:   +1 978-692-4482

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