diff options
-rw-r--r-- | ChangeLog | 8 | ||||
-rwxr-xr-x | tool/instruction.rb | 4 | ||||
-rw-r--r-- | vm_exec.h | 4 |
3 files changed, 14 insertions, 2 deletions
@@ -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]};" @@ -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 */ |