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

Re: Stack overflows (was: Re: Future of Debian uncertain?)



On Thu, Feb 27, 2003 at 09:11:22PM +0100, Falk Hueffner wrote:
> Craig Dickson <crdic@pacbell.net> writes:
> 
> > Falk Hueffner wrote:
> > > It's not that difficult to hit when you do functional style
> > > programming, e. g.
> > 
> > You clipped the context enough that I'm not quite sure what you mean by
> > "it", but from the subject I'll assume "it" is a stack overflow. In
> > which case functional programming is actually _less_ likely to require a
> > huge stack if you have tail recursion and know how to use it.
> 
> Well, it's often too much hassle to write tail recursive.

If a task can be expressed in a tail-recursive fashion, and gain
efficiency as a result, then I fully expect any serious application
programmer to make use of it.

> > Also, most functional languages, in my experience, don't use a
> > statically-allocated stack for subroutine call returns.
> 
> Ocaml does. It uses the plain OS-provided stack.

Only functional languages with support for full continuations need
heap-allocated stacks.

> > > It would already be quite helpful IMHO if one didn't just get a
> > > SEGV, since that usually indicates a program error.  I don't think
> > > there are any free signal numbers, though. Maybe one should send
> > > SIGBUS or something?
> > 
> > A stack overflow is not a bus error. It's a segment violation. And quite
> > often, a stack overflow _is_ a program error.
> 
> Still it'd be nice IMHO to differentiate it from other segment
> violations.

This is Unix we're talking about, remember.  It's not supposed to be
nice for the applications programmer.

Anyway, running out of stack is similar to running out of tape on a
turing machine.  Maybe we should signal
SIGCANNOLONGERPRETENDTOBEUNIVERSALTURINGMACHINE.

Be thankful I didn't leave out half the vowels.

-- 
; Matthew Danish <mdanish@andrew.cmu.edu>
; OpenPGP public key: C24B6010 on keyring.debian.org
; Signed or encrypted mail welcome.
; "There is no dark side of the moon really; matter of fact, it's all dark."



Reply to: