ruby-changes:21921
From: nobu <ko1@a...>
Date: Wed, 7 Dec 2011 18:56:13 +0900 (JST)
Subject: [ruby-changes:21921] nobu:r33970 (trunk): * vm.c (vm_set_top_stack, vm_set_eval_stack): check for stack
nobu 2011-12-07 18:56:01 +0900 (Wed, 07 Dec 2011) New Revision: 33970 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=33970 Log: * vm.c (vm_set_top_stack, vm_set_eval_stack): check for stack overflow with stack_max before push new frame. [ruby-core:41520] [Bug #5720] * vm.c (vm_set_main_stack): no stack overflow chances after vm_set_eval_stack(). Modified files: trunk/ChangeLog trunk/test/ruby/test_exception.rb trunk/vm.c Index: ChangeLog =================================================================== --- ChangeLog (revision 33969) +++ ChangeLog (revision 33970) @@ -1,3 +1,12 @@ +Wed Dec 7 18:55:56 2011 Nobuyoshi Nakada <nobu@r...> + + * vm.c (vm_set_top_stack, vm_set_eval_stack): check for stack + overflow with stack_max before push new frame. [ruby-core:41520] + [Bug #5720] + + * vm.c (vm_set_main_stack): no stack overflow chances after + vm_set_eval_stack(). + Wed Dec 7 09:58:15 2011 Eric Hodel <drbrain@s...> * ext/bigdecimal/bigdecimal.c: Document +@, -@, hash, INFINITY, Nan. Index: vm.c =================================================================== --- vm.c (revision 33969) +++ vm.c (revision 33970) @@ -106,11 +106,10 @@ /* for return */ rb_vm_set_finish_env(th); + CHECK_STACK_OVERFLOW(th->cfp, iseq->local_size + iseq->stack_max); vm_push_frame(th, iseq, VM_FRAME_MAGIC_TOP, th->top_self, 0, iseq->iseq_encoded, th->cfp->sp, 0, iseq->local_size); - - CHECK_STACK_OVERFLOW(th->cfp, iseq->stack_max); } static void @@ -122,6 +121,8 @@ /* for return */ rb_vm_set_finish_env(th); + + CHECK_STACK_OVERFLOW(th->cfp, iseq->local_size + iseq->stack_max); vm_push_frame(th, iseq, VM_FRAME_MAGIC_EVAL, block->self, GC_GUARDED_PTR(block->dfp), iseq->iseq_encoded, th->cfp->sp, block->lfp, iseq->local_size); @@ -129,8 +130,6 @@ if (cref) { th->cfp->dfp[-1] = (VALUE)cref; } - - CHECK_STACK_OVERFLOW(th->cfp, iseq->stack_max); } static void @@ -152,8 +151,6 @@ if (bind && iseq->local_size > 0) { bind->env = rb_vm_make_env_object(th, th->cfp); } - - CHECK_STACK_OVERFLOW(th->cfp, iseq->stack_max); } rb_control_frame_t * Index: test/ruby/test_exception.rb =================================================================== --- test/ruby/test_exception.rb (revision 33969) +++ test/ruby/test_exception.rb (revision 33970) @@ -328,4 +328,10 @@ def test_errno assert_equal(Encoding.find("locale"), Errno::EINVAL.new.message.encoding) end + + def test_too_many_args_in_eval + bug5720 = '[ruby-core:41520]' + arg_string = (0...140000).to_a.join(", ") + assert_raise(SystemStackError, bug5720) {eval "raise(#{arg_string})"} + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/