[1259] in Coldmud discussion meeting

root meeting help first previous next last

[COLD] PATCH: Bug reported by Kipp

daemon@ATHENA.MIT.EDU (Mon Mar 24 18:58:52 1997 )

Date: Tue, 25 Mar 1997 00:47:21 +0100 (MET)
From: Miroslav Silovic <silovic@public.srce.hr>
To: coldstuff@cold.org


I *love* bugs that can be reproduced by eval. This patch fixes the
refcounting bombs that happen when current method gets wiped, and then
the task throws. Things that traceback wanted weren't there.



*** Genesis-1.0p26/src/execute.c	Tue Mar 25 00:43:09 1997
--- Genesis-1.0p26-new/src/execute.c	Tue Mar 25 00:43:10 1997
***************
*** 1488,1498 ****
  	va_end(arg);
      }
      else
  	str=NULL;
  
!     interp_error(error, str);
      if (str)
  	string_discard(str);
  }
  
  void interp_error(Ident error, cStr *explanation)
--- 1488,1509 ----
  	va_end(arg);
      }
      else
  	str=NULL;
  
!     {
! 	Method *method = NULL;
! 
! 	/* protect the method in the current frame, if there is any - I
! 	   have no idea what can call cthrow... This will prevent unexpected
! 	   refcounting bombs during the frame_return sequence */
! 	if (cur_frame)
! 	    method = method_dup(cur_frame->method);
! 	interp_error(error, str);
! 	if (method)
! 	    method_discard(method);
!     }
      if (str)
  	string_discard(str);
  }
  
  void interp_error(Ident error, cStr *explanation)
***************
*** 1545,1556 ****
  
      /* The second through fifth elements are the current method info. */
      fill_in_method_info(d);
  
      /* Return from the current method, and propagate the error. */
!     frame_return();
!     start_error(error, explanation, arg, location);
      list_discard(location);
  }
  
  INTERNAL void out_of_ticks_error(void)
  {
--- 1556,1572 ----
  
      /* The second through fifth elements are the current method info. */
      fill_in_method_info(d);
  
      /* Return from the current method, and propagate the error. */
!     {
! 	/* protect the current method, so that strings live long enough */
! 	Method *method = method_dup(cur_frame->method);
! 	frame_return();
! 	start_error(error, explanation, arg, location);
! 	method_discard(method);
!     }
      list_discard(location);
  }
  
  INTERNAL void out_of_ticks_error(void)
  {
***************
*** 1569,1583 ****
  
      /* The second through fifth elements are the current method info. */
      fill_in_method_info(d);
  
      /* Don't give the topmost frame a chance to return. */
!     frame_return();
  
!     if (!explanation)
!         explanation = string_from_chars("Out of ticks", 12);
!     start_error(methoderr_id, explanation, NULL, location);
      list_discard(location);
  }
  
  INTERNAL void start_error(Ident error, cStr *explanation, cData *arg,
                          cList * location)
--- 1585,1603 ----
  
      /* The second through fifth elements are the current method info. */
      fill_in_method_info(d);
  
      /* Don't give the topmost frame a chance to return. */
!     {
! 	Method *method = method_dup(cur_frame->method);
! 	frame_return();
  
! 	if (!explanation)
! 	    explanation = string_from_chars("Out of ticks", 12);
! 	start_error(methoderr_id, explanation, NULL, location);
! 	method_discard(method);
!     }
      list_discard(location);
  }
  
  INTERNAL void start_error(Ident error, cStr *explanation, cData *arg,
                          cList * location)