ruby-changes:20720
From: ktsj <ko1@a...>
Date: Sun, 31 Jul 2011 11:32:58 +0900 (JST)
Subject: [ruby-changes:20720] ktsj:r32768 (trunk): * vm.c: check if cfp is valid. [Bug #5083]
ktsj 2011-07-31 11:32:48 +0900 (Sun, 31 Jul 2011) New Revision: 32768 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=32768 Log: * vm.c: check if cfp is valid. [Bug #5083] [ruby-dev:44208] Modified files: trunk/ChangeLog trunk/test/ruby/test_thread.rb trunk/vm.c Index: ChangeLog =================================================================== --- ChangeLog (revision 32767) +++ ChangeLog (revision 32768) @@ -1,3 +1,7 @@ +Sun Jul 31 11:31:07 2011 Kazuki Tsujimoto <kazuki@c...> + + * vm.c: check if cfp is valid. [Bug #5083] [ruby-dev:44208] + Sun Jul 31 09:18:28 2011 Eric Hodel <drbrain@s...> * lib/rdoc: Update to RDoc 3.9. Fixed `ri []`, stopdoc creating an Index: vm.c =================================================================== --- vm.c (revision 32767) +++ vm.c (revision 32768) @@ -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: test/ruby/test_thread.rb =================================================================== --- test/ruby/test_thread.rb (revision 32767) +++ test/ruby/test_thread.rb (revision 32768) @@ -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/