[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: stack overflow
From: |
Ludovic Courtès |
Subject: |
Re: stack overflow |
Date: |
Thu, 14 Feb 2008 09:48:15 +0100 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) |
Hi,
Neil Jerram <address@hidden> writes:
> Not to disagree with anything that's already been said in this
> thread... But I wonder if there is a way to make Guile's stack
> overflow checking a bit less fragile - i.e. less subject to the
> behaviour of particular compilers / OSs / optimization options?
>
> I think all we're really trying to do, with the stack overflow
> feature, is guard against a suspected infinite recursion, without
> resorting to crashing the whole program. Perhaps there is a cunning
> way to do that without having to set an arbitrary stack depth limit?
> Any ideas would be most welcome.
A platform-independent way to achieve this would be to somehow count
Scheme stack frames (since we are concerned with stack overflows in
Scheme code). Of course, we don't want to traverse the whole Scheme
stack to determine the stack depth. So the evaluator would need to
maintain the current stack depth in an integer.
In `eval.i.c', instead of:
#ifdef EVAL_STACK_CHECKING
if (scm_stack_checking_enabled_p && SCM_STACK_OVERFLOW_P (&proc))
{
We could have something along the lines of:
#ifdef EVAL_STACK_CHECKING
if (scm_stack_checking_enabled_p)
{
scm_i_eval_stack_depth++;
if (scm_i_eval_stack_depth > SCM_STACK_LIMIT)
{
We must also change `RETURN' to do "scm_i_eval_stack_depth--".
Hopefully it's not too unreasonable performance-wise.
What do you think?
Thanks,
Ludovic.
Re: stack overflow, Han-Wen Nienhuys, 2008/02/16