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

ruby-changes:47259

From: nobu <ko1@a...>
Date: Thu, 20 Jul 2017 11:43:52 +0900 (JST)
Subject: [ruby-changes:47259] nobu:r59374 (trunk): compile.c: restore stack at return

nobu	2017-07-20 11:43:45 +0900 (Thu, 20 Jul 2017)

  New Revision: 59374

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

  Log:
    compile.c: restore stack at return
    
    * compile.c (iseq_compile_each0): restore the stack depth after
      return to the previous depth, to fix the stack depth at
      returning from rescue iseq.  [ruby-core:82108] [Bug #13755]

  Modified files:
    trunk/compile.c
    trunk/test/ruby/test_syntax.rb
Index: compile.c
===================================================================
--- compile.c	(revision 59373)
+++ compile.c	(revision 59374)
@@ -5653,9 +5653,12 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK https://github.com/ruby/ruby/blob/trunk/compile.c#L5653
 	    enum iseq_type parent_type;
 
 	    if (type == ISEQ_TYPE_TOP || type == ISEQ_TYPE_MAIN) {
+		LABEL *splabel = NEW_LABEL(line);
+		ADD_LABEL(ret, splabel);
 		ADD_ADJUST(ret, line, 0);
 		ADD_INSN(ret, line, putnil);
 		ADD_INSN(ret, line, leave);
+		ADD_ADJUST_RESTORE(ret, splabel);
 	    }
 	    else if ((type == ISEQ_TYPE_RESCUE || type == ISEQ_TYPE_ENSURE) &&
 		     parent_iseq &&
Index: test/ruby/test_syntax.rb
===================================================================
--- test/ruby/test_syntax.rb	(revision 59373)
+++ test/ruby/test_syntax.rb	(revision 59374)
@@ -986,6 +986,7 @@ eom https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L986
       raise((return; "should not raise"))
       begin raise; ensure return; end; self
       begin raise; ensure return; end and self
+      nil&defined?0--begin e=no_method_error(); return; 0;end
     end;
     all_assertions(feature4840) do |a|
       code.each_line do |s|

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

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