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

ruby-changes:30142

From: ko1 <ko1@a...>
Date: Fri, 26 Jul 2013 19:28:38 +0900 (JST)
Subject: [ruby-changes:30142] ko1:r42194 (trunk): * vm_exec.h, tool/instruction.rb: not an error, but a BUG if stack

ko1	2013-07-26 19:28:26 +0900 (Fri, 26 Jul 2013)

  New Revision: 42194

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

  Log:
    * vm_exec.h, tool/instruction.rb: not an error, but a BUG if stack
      overflow checking failed just before/after the beginning of an
      instruction. It should be treated as a BUG.
      Please tell us if your code cause BUG with this problem.
      This check will removed soon (for performance).

  Modified files:
    trunk/ChangeLog
    trunk/tool/instruction.rb
    trunk/vm_exec.h

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 42193)
+++ ChangeLog	(revision 42194)
@@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Jul 26 19:25:17 2013  Koichi Sasada  <ko1@a...>
+
+	* vm_exec.h, tool/instruction.rb: not an error, but a BUG if stack
+	  overflow checking failed just before/after the beginning of an
+	  instruction. It should be treated as a BUG.
+	  Please tell us if your code cause BUG with this problem.
+	  This check will removed soon (for performance).
+
 Fri Jul 26 18:30:14 2013  Koichi Sasada  <ko1@a...>
 
 	* array.c (ary_memcpy): cast to int to suppress a warning.
Index: vm_exec.h
===================================================================
--- vm_exec.h	(revision 42193)
+++ vm_exec.h	(revision 42194)
@@ -169,5 +169,9 @@ default:                        \ https://github.com/ruby/ruby/blob/trunk/vm_exec.h#L169
 #endif
 
 #define SCREG(r) (reg_##r)
+#define CHECK_VM_STACK_OVERFLOW_FOR_INSN(cfp, margin) \
+  if ((VALUE *)((char *)(((VALUE *)(cfp)->sp) + (margin)) + sizeof(rb_control_frame_t)) >= ((VALUE *)(cfp))) { \
+      rb_bug("CHECK_VM_STACK_OVERFLOW_FOR_INSN: should not overflow here. Please contact ruby-core/dev with your (a part of) script. This check will be removed soon."); \
+  } while (0);
 
 #endif /* RUBY_VM_EXEC_H */
Index: tool/instruction.rb
===================================================================
--- tool/instruction.rb	(revision 42193)
+++ tool/instruction.rb	(revision 42194)
@@ -692,7 +692,7 @@ class RubyVM https://github.com/ruby/ruby/blob/trunk/tool/instruction.rb#L692
 
       n = 0
       push_ba.each {|pushs| n += pushs.length}
-      commit "  CHECK_VM_STACK_OVERFLOW(REG_CFP, #{n});" if n > 0
+      commit "  CHECK_VM_STACK_OVERFLOW_FOR_INSN(REG_CFP, #{n});" if n > 0
       push_ba.each{|pushs|
         pushs.each{|r|
           commit "  PUSH(SCREG(#{r}));"
@@ -842,7 +842,7 @@ class RubyVM https://github.com/ruby/ruby/blob/trunk/tool/instruction.rb#L842
       each_footer_stack_val(insn){|v|
         n += 1 unless v[2]
       }
-      commit "  CHECK_VM_STACK_OVERFLOW(REG_CFP, #{n});" if n > 0
+      commit "  CHECK_VM_STACK_OVERFLOW_FOR_INSN(REG_CFP, #{n});" if n > 0
       each_footer_stack_val(insn){|v|
         if v[2]
           commit "  SCREG(#{v[2]}) = #{v[1]};"

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

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