From 22468a4f92c7fa7a08e53a674285183b1af49ed4 Mon Sep 17 00:00:00 2001 From: ko1 Date: Tue, 6 Aug 2013 08:33:05 +0000 Subject: * vm_insnhelper.c (vm_push_frame): fix stack overflow check codes. Stack overflow check should be done *after* pushing a stack frame. However, some stack overflow checking codes checked *before* pushing a stack frame with iseq->stack_max. To solve this problem, add a new parameter `stack_max' to specify a possible consuming stack size. * vm_core.h (CHECK_VM_STACK_OVERFLOW0): add to share the stack overflow checking code. * insns.def: catch up this change. * vm.c, vm_eval.c: ditto. * test/ruby/test_exception.rb: add a stack overflow test. This code is reported by nobu. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42398 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- vm_core.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'vm_core.h') diff --git a/vm_core.h b/vm_core.h index 0701c5c4a9..1b5d8deea3 100644 --- a/vm_core.h +++ b/vm_core.h @@ -854,11 +854,13 @@ int rb_autoloading_value(VALUE mod, ID id, VALUE* value); #define sysstack_error GET_VM()->special_exceptions[ruby_error_sysstack] -#define CHECK_VM_STACK_OVERFLOW(cfp, margin) do \ - if ((VALUE *)((char *)(((VALUE *)(cfp)->sp) + (margin)) + sizeof(rb_control_frame_t)) >= ((VALUE *)(cfp))) { \ - vm_stackoverflow(); \ - } \ -while (0) +#define CHECK_VM_STACK_OVERFLOW0(cfp, sp, margin) do { \ + if ((VALUE *)((char *)((VALUE *)(sp) + (margin)) + sizeof(rb_control_frame_t)) >= ((VALUE *)(cfp))) { \ + vm_stackoverflow(); \ + } \ +} while (0) + +#define CHECK_VM_STACK_OVERFLOW(cfp, margin) CHECK_VM_STACK_OVERFLOW0((cfp), (cfp)->sp, margin) /* for thread */ -- cgit v1.2.3