bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-gnulib] Re: alloca


From: Bruno Haible
Subject: Re: [Bug-gnulib] Re: alloca
Date: Thu, 13 Nov 2003 13:32:52 +0100
User-agent: KMail/1.5

Simon Josefsson wrote:
> Having a new GCC inline'd function 'void *alloca_safe(size_t SIZE)',
> that can return NULL if there is not enough stack space might be the
> best.

It's the OS which determines whether an alloca() succeeds or not. You cannot
know in advance.

Furthermore, _when_ alloca_safe() fails, you don't usually have any more
room than for a few recursive calls even without alloca(). So it means you
have wasted too much stack space earlier. But at this moment it's too late.

> Considering that GNU systems have dynamically
> increasing stack space, if I recall correctly, the abort-with-error
> approach would work perfectly on GNU systems, and only rarely fail on
> non-GNU systems.

I don't know whether the Hurd implements a stack size limit, but at least
on Linux there is a configurable stack size limit, and it is usually turned
on to something like 8 MB. This is needed to avoid that a simple endless
recursion program takes down the entire machine in less than 30 seconds.

Bruno





reply via email to

[Prev in Thread] Current Thread [Next in Thread]