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

ruby-changes:13285

From: nobu <ko1@a...>
Date: Wed, 23 Sep 2009 11:28:24 +0900 (JST)
Subject: [ruby-changes:13285] Ruby:r25048 (trunk): * tool/instruction.rb (make_header_prepare_stack): check stack

nobu	2009-09-23 11:28:08 +0900 (Wed, 23 Sep 2009)

  New Revision: 25048

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=25048

  Log:
    * tool/instruction.rb (make_header_prepare_stack): check stack
      overflow.  [ruby-core:25714]
    
    * tool/instruction.rb (make_footer_stack_val): ditto.

  Modified files:
    trunk/ChangeLog
    trunk/bootstraptest/test_eval.rb
    trunk/tool/instruction.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 25047)
+++ ChangeLog	(revision 25048)
@@ -1,3 +1,11 @@
+Wed Sep 23 11:28:06 2009  Nobuyoshi Nakada  <nobu@r...>
+
+	* tool/instruction.rb (make_header_prepare_stack): check stack
+	  overflow.  [ruby-core:25714]
+
+	* tool/instruction.rb (make_footer_stack_val): ditto.
+
+
 Wed Sep 23 05:03:36 2009  Marc-Andre Lafortune  <ruby-core@m...>
 
 	* proc.c (umethod_bind, rb_mod_define_method): Fix bug that
Index: bootstraptest/test_eval.rb
===================================================================
--- bootstraptest/test_eval.rb	(revision 25047)
+++ bootstraptest/test_eval.rb	(revision 25048)
@@ -308,3 +308,14 @@
     binding
   end
 }, '[ruby-core:25125]'
+
+assert_normal_exit %q{
+  hash = {}
+  ("aaaa".."matz").each_with_index do |s, i|
+    hash[s] = i
+  end
+  begin
+    eval "class C; @@h = #{hash.inspect}; end"
+  rescue SystemStackError
+  end
+}, '[ruby-core:25714]'
Index: tool/instruction.rb
===================================================================
--- tool/instruction.rb	(revision 25047)
+++ tool/instruction.rb	(revision 25048)
@@ -684,6 +684,9 @@
       push_ba = insn.pushsc
       raise "unsupport" if push_ba[0].size > 0 && push_ba[1].size > 0
 
+      n = 0
+      push_ba.each {|pushs| n += pushs.length}
+      commit "  CHECK_STACK_OVERFLOW(REG_CFP, #{n});" if n > 0
       push_ba.each{|pushs|
         pushs.each{|r|
           commit "  PUSH(SCREG(#{r}));"
@@ -816,13 +819,22 @@
       commit  "  #define LABEL_IS_SC(lab) LABEL_##lab##_###{insn.sc.size == 0 ? 't' : 'f'}"
     end
 
+    def each_footer_stack_val insn
+      insn.rets.reverse_each{|v|
+        break if v[1] == '...'
+        yield v
+      }
+    end
+
     def make_footer_stack_val insn
       comment "  /* push stack val */"
 
-      insn.rets.reverse_each{|v|
-        if v[1] == '...'
-          break
-        end
+      n = 0
+      each_footer_stack_val(insn){|v|
+        n += 1 unless v[2]
+      }
+      commit "  CHECK_STACK_OVERFLOW(REG_CFP, #{n});" if n > 0
+      each_footer_stack_val(insn){|v|
         if v[2]
           commit "  SCREG(#{v[2]}) = #{v[1]};"
         else

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

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