From 2ddafc2239d07c222d63c9fc6c4d98eb29f4711c Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Sat, 12 Dec 2009 17:29:54 +0900 Subject: [PATCH] recovering gracefully from out-of-stack-space errors --- eval.c | 6 ++++-- include/chibi/sexp.h | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/eval.c b/eval.c index 6f478fea..87e76051 100644 --- a/eval.c +++ b/eval.c @@ -1313,8 +1313,10 @@ sexp sexp_vm (sexp ctx, sexp proc) { goto make_call; case OP_CALL: #if USE_CHECK_STACK - if (top+16 >= SEXP_INIT_STACK_SIZE) - errx(70, "out of stack space at %ld", top); + if (top+16 >= SEXP_INIT_STACK_SIZE) { + _ARG1 = sexp_global(ctx, SEXP_G_OOS_ERROR); + goto end_loop; + } #endif i = sexp_unbox_fixnum(_WORD0); tmp1 = _ARG1; diff --git a/include/chibi/sexp.h b/include/chibi/sexp.h index 7e4a1a10..1b487a54 100644 --- a/include/chibi/sexp.h +++ b/include/chibi/sexp.h @@ -668,7 +668,8 @@ enum sexp_context_globals { #if ! USE_GLOBAL_SYMBOLS SEXP_G_SYMBOLS, #endif - SEXP_G_OOM_ERROR, + SEXP_G_OOM_ERROR, /* out of memory exception object */ + SEXP_G_OOS_ERROR, /* out of stack exception object */ SEXP_G_QUOTE_SYMBOL, SEXP_G_QUASIQUOTE_SYMBOL, SEXP_G_UNQUOTE_SYMBOL,