Branch: Tag:

2004-06-01

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

Improved handling of out-of-stack errors.

Rev: src/error.c:1.124
Rev: src/interpret.c:1.350

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: error.c,v 1.123 2004/05/19 00:04:38 nilsson Exp $ + || $Id: error.c,v 1.124 2004/06/01 19:12:06 mast Exp $   */      #define NO_PIKE_SHORTHAND
23:   #include "threads.h"   #include "gc.h"    - RCSID("$Id: error.c,v 1.123 2004/05/19 00:04:38 nilsson Exp $"); + RCSID("$Id: error.c,v 1.124 2004/06/01 19:12:06 mast Exp $");      /* __attribute__ only applies to function declarations, not    definitions, so we disable them here. */
57:    "Division by zero.\n";      /* -  * Attempt to inhibit throwing of errors if possible. -  * Used by exit_on_error() to avoid infinite sprintf() loops. -  */ - int Pike_inhibit_errors = 0; -  - /* +     * Recoveries handling.    */   
305:    pike_throw(); /* Hope someone is catching, or we will be out of balls. */   }    + static int inhibit_errors = 0; +    PMOD_EXPORT void exit_on_error(const void *msg)   {    ONERROR tmp;    SET_ONERROR(tmp,fatal_on_error,"Fatal in exit_on_error!");    d_flag=0; -  +  Pike_interpreter.trace_level = 0;    -  /* Tell sprintf(), describe_svalue() et al not to throw errors -  * if possible. -  */ -  Pike_inhibit_errors = 1; +  if (inhibit_errors) +  fprintf (stderr, "Got recursive error in exit_on_error: %s\n", (char *) msg);    -  +  else { +  dynamic_buffer save_buf; +  char *s; +  struct svalue thrown; +  +  inhibit_errors = 1; +    #ifdef PIKE_DEBUG    if (d_flag) {    fprintf(stderr,"%s\n",(char *)msg);    dump_backlog();    }   #endif -  +     fprintf(stderr,"%s\n",(char *)msg); - #ifdef PIKE_DEBUG -  { -  dynamic_buffer save_buf; -  char *s; -  struct svalue thrown; +  +  /* We've reserved LOW_SVALUE_STACK_MARGIN and LOW_C_STACK_MARGIN +  * for this. */ +  Pike_interpreter.svalue_stack_margin = 0; +  Pike_interpreter.c_stack_margin = 0;    fprintf(stderr,"Attempting to dump raw error: (may fail)\n");    init_buf(&save_buf);    move_svalue (&thrown, &throw_value);
338: Inside #if defined(PIKE_DEBUG)
   fprintf(stderr,"%s\n",s);    free(s);    } - #endif +     exit(1);   }