* vm.c: check if cfp is valid. [Bug #5083] [ruby-dev:44208]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32768 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ktsj 2011-07-31 02:32:48 +00:00
Родитель 89b601d176
Коммит 70189a8cfd
3 изменённых файлов: 27 добавлений и 0 удалений

Просмотреть файл

@ -1,3 +1,7 @@
Sun Jul 31 11:31:07 2011 Kazuki Tsujimoto <kazuki@callcc.net>
* vm.c: check if cfp is valid. [Bug #5083] [ruby-dev:44208]
Sun Jul 31 09:18:28 2011 Eric Hodel <drbrain@segment7.net>
* lib/rdoc: Update to RDoc 3.9. Fixed `ri []`, stopdoc creating an

Просмотреть файл

@ -604,6 +604,18 @@ class TestThread < Test::Unit::TestCase
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

11
vm.c
Просмотреть файл

@ -854,6 +854,10 @@ rb_vm_cref(void)
{
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_vm_cbase(void)
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 @@ m_core_set_postexe(VALUE self, VALUE iseqval)
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);