aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rwxr-xr-xtool/instruction.rb4
-rw-r--r--vm_exec.h4
3 files changed, 14 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 8b96d58d5c..37beb6c848 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Fri Jul 26 19:25:17 2013 Koichi Sasada <ko1@atdot.net>
+
+ * 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@atdot.net>
* array.c (ary_memcpy): cast to int to suppress a warning.
diff --git a/tool/instruction.rb b/tool/instruction.rb
index 7083f1757f..9dbc3ae6b8 100755
--- a/tool/instruction.rb
+++ b/tool/instruction.rb
@@ -692,7 +692,7 @@ class RubyVM
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
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]};"
diff --git a/vm_exec.h b/vm_exec.h
index 3c7e35e238..b785c4fdd3 100644
--- a/vm_exec.h
+++ b/vm_exec.h
@@ -169,5 +169,9 @@ default: \
#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 */