[前][次][番号順一覧][スレッド一覧]

ruby-changes:46276

From: nobu <ko1@a...>
Date: Tue, 18 Apr 2017 17:34:46 +0900 (JST)
Subject: [ruby-changes:46276] nobu:r58389 (trunk): eval.c: fix exit inside TAG

nobu	2017-04-18 17:34:40 +0900 (Tue, 18 Apr 2017)

  New Revision: 58389

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58389

  Log:
    eval.c: fix exit inside TAG
    
    * eval.c (setup_exception): do not exit by goto inside
      PUSH_TAG/POP_TAG.  it causes an infinite loop.

  Modified files:
    trunk/eval.c
Index: eval.c
===================================================================
--- eval.c	(revision 58388)
+++ eval.c	(revision 58389)
@@ -492,14 +492,11 @@ setup_exception(rb_thread_t *th, int tag https://github.com/ruby/ruby/blob/trunk/eval.c#L492
 
     file = rb_source_loc(&line);
     if ((file && !NIL_P(mesg)) || (cause != Qundef))  {
-	VALUE at;
 	int status;
 
 	TH_PUSH_TAG(th);
-	if ((status = EXEC_TAG()) == 0) {
-	    VALUE bt;
-	    if (rb_threadptr_set_raised(th)) goto fatal;
-	    bt = rb_get_backtrace(mesg);
+	if (EXEC_TAG() == 0 && !(status = rb_threadptr_set_raised(th))) {
+	    VALUE bt = rb_get_backtrace(mesg);
 	    if (!NIL_P(bt) || cause == Qundef) {
 		if (OBJ_FROZEN(mesg)) {
 		    mesg = rb_obj_dup(mesg);
@@ -509,13 +506,14 @@ setup_exception(rb_thread_t *th, int tag https://github.com/ruby/ruby/blob/trunk/eval.c#L506
 		exc_setup_cause(mesg, cause);
 	    }
 	    if (NIL_P(bt)) {
-		at = rb_threadptr_backtrace_object(th);
+		VALUE at = rb_threadptr_backtrace_object(th);
 		rb_ivar_set(mesg, idBt_locations, at);
 		set_backtrace(mesg, at);
 	    }
 	    rb_threadptr_reset_raised(th);
 	}
 	TH_POP_TAG();
+	if (status) goto fatal;
     }
 
     if (!NIL_P(mesg)) {

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]