ruby-changes:20721
From: ktsj <ko1@a...>
Date: Sun, 31 Jul 2011 11:57:29 +0900 (JST)
Subject: [ruby-changes:20721] ktsj:r32769 (ruby_1_9_3): * backport r32768 from trunk.
ktsj 2011-07-31 11:57:18 +0900 (Sun, 31 Jul 2011) New Revision: 32769 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=32769 Log: * backport r32768 from trunk. * vm.c: check if cfp is valid. [Bug #5083] [ruby-dev:44208] Modified files: branches/ruby_1_9_3/ChangeLog branches/ruby_1_9_3/test/ruby/test_thread.rb branches/ruby_1_9_3/vm.c Index: ruby_1_9_3/ChangeLog =================================================================== --- ruby_1_9_3/ChangeLog (revision 32768) +++ ruby_1_9_3/ChangeLog (revision 32769) @@ -1,3 +1,9 @@ +Sun Jul 31 11:31:07 2011 Kazuki Tsujimoto <kazuki@c...> + + * backport r32768 from trunk. + + * vm.c: check if cfp is valid. [Bug #5083] [ruby-dev:44208] + Sat Jul 31 01:23:45 2011 Kenta Murata <mrkn@m...> * backport r32762 from trunk. Index: ruby_1_9_3/vm.c =================================================================== --- ruby_1_9_3/vm.c (revision 32768) +++ ruby_1_9_3/vm.c (revision 32769) @@ -854,6 +854,10 @@ { rb_thread_t *th = GET_THREAD(); rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(th, th->cfp); + + if (cfp == 0) { + rb_raise(rb_eRuntimeError, "Can't call on top of Fiber or Thread"); + } return vm_get_cref(cfp->iseq, cfp->lfp, cfp->dfp); } @@ -875,6 +879,9 @@ rb_thread_t *th = GET_THREAD(); rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(th, th->cfp); + if (cfp == 0) { + rb_raise(rb_eRuntimeError, "Can't call on top of Fiber or Thread"); + } return vm_get_cbase(cfp->iseq, cfp->lfp, cfp->dfp); } @@ -1971,6 +1978,10 @@ rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(th, th->cfp); VALUE proc; + if (cfp == 0) { + rb_bug("m_core_set_postexe: unreachable"); + } + GetISeqPtr(iseqval, blockiseq); blockptr = RUBY_VM_GET_BLOCK_PTR_IN_CFP(cfp); Index: ruby_1_9_3/test/ruby/test_thread.rb =================================================================== --- ruby_1_9_3/test/ruby/test_thread.rb (revision 32768) +++ ruby_1_9_3/test/ruby/test_thread.rb (revision 32769) @@ -604,6 +604,18 @@ end INPUT end + + def test_no_valid_cfp + bug5083 = '[ruby-dev:44208]' + error = assert_raise(RuntimeError) do + Thread.new(&Module.method(:nesting)).join + end + assert_equal("Can't call on top of Fiber or Thread", error.message, bug5083) + error = assert_raise(RuntimeError) do + Thread.new(:to_s, &Module.method(:undef_method)).join + end + assert_equal("Can't call on top of Fiber or Thread", error.message, bug5083) + end end class TestThreadGroup < Test::Unit::TestCase -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/