Branch: Tag:

2004-06-01

2004-06-01 19:12:05 by Martin Stjernholm <mast@lysator.liu.se>

Improved handling of out-of-stack errors.

Rev: src/error.c:1.123
Rev: src/interpret.c:1.351

2:   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: interpret.c,v 1.350 2004/05/21 19:02:49 grubba Exp $ + || $Id: interpret.c,v 1.351 2004/06/01 19:12:05 mast Exp $   */      #include "global.h" - RCSID("$Id: interpret.c,v 1.350 2004/05/21 19:02:49 grubba Exp $"); + RCSID("$Id: interpret.c,v 1.351 2004/06/01 19:12:05 mast Exp $");   #include "interpret.h"   #include "object.h"   #include "program.h"
63:      /* Keep some margin on the stack space checks. They're lifted when    * handle_error runs to give it some room. */ - #define SVALUE_STACK_MARGIN 100 /* Tested in 7.1: 40 was enough, 30 wasn't. */ - #define C_STACK_MARGIN 8000 /* Tested in 7.1: 3000 was enough, 2600 wasn't. */ + /* Observed in 7.1: 40 was enough, 30 wasn't. */ + #define SVALUE_STACK_MARGIN (100 + LOW_SVALUE_STACK_MARGIN) + /* Observed in 7.4: 11000 was enough, 10000 wasn't. */ + #define C_STACK_MARGIN (20000 + LOW_C_STACK_MARGIN)    -  + /* Another extra margin to use while dumping the raw error in +  * exit_on_error, so that backtrace_frame._sprintf can be called +  * then. */ + #define LOW_SVALUE_STACK_MARGIN 20 + #define LOW_C_STACK_MARGIN 500 +    #ifdef HAVE_COMPUTED_GOTO   PIKE_OPCODE_T *fcode_to_opcode = NULL;   struct op_2_f *opcode_to_fcode = NULL;
1979:      void mega_apply(enum apply_type type, INT32 args, void *arg1, void *arg2)   { -  check_c_stack(8192); +  /* The C stack margin is normally 8 kb, but if we get here during a +  * lowered margin then don't fail just because of that, unless it's +  * practically zero. */ +  check_c_stack(Pike_interpreter.c_stack_margin ? +  Pike_interpreter.c_stack_margin : 100); +     if(low_mega_apply(type, args, arg1, arg2))    {    eval_instruction(Pike_fp->pc
2077:   {    dmalloc_touch_svalue(&throw_value);    -  if (Pike_interpreter.svalue_stack_margin) { +  if (Pike_interpreter.svalue_stack_margin > LOW_SVALUE_STACK_MARGIN) {    int old_t_flag = Pike_interpreter.trace_level;    Pike_interpreter.trace_level = 0; -  Pike_interpreter.svalue_stack_margin = 0; -  Pike_interpreter.c_stack_margin = 0; +  Pike_interpreter.svalue_stack_margin = LOW_SVALUE_STACK_MARGIN; +  Pike_interpreter.c_stack_margin = LOW_C_STACK_MARGIN;    *(Pike_sp++) = throw_value;    dmalloc_touch_svalue(Pike_sp-1);    throw_value.type=T_INT;