mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Fiber also has same issue. [Bug #13313]
* thread.c (rb_vm_proc_local_ep): added. * cont.c (rb_fiber_start): use rb_vm_proc_local_ep(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57970 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1943242a46
commit
3651c0aa00
4 changed files with 25 additions and 3 deletions
2
cont.c
2
cont.c
|
@ -1275,7 +1275,7 @@ rb_fiber_start(void)
|
||||||
argv = (argc = cont->argc) > 1 ? RARRAY_CONST_PTR(args) : &args;
|
argv = (argc = cont->argc) > 1 ? RARRAY_CONST_PTR(args) : &args;
|
||||||
cont->value = Qnil;
|
cont->value = Qnil;
|
||||||
th->errinfo = Qnil;
|
th->errinfo = Qnil;
|
||||||
th->root_lep = rb_vm_ep_local_ep(vm_block_ep(&proc->block));
|
th->root_lep = rb_vm_proc_local_ep(cont->saved_thread.first_proc);
|
||||||
th->root_svar = Qfalse;
|
th->root_svar = Qfalse;
|
||||||
fib->status = RUNNING;
|
fib->status = RUNNING;
|
||||||
|
|
||||||
|
|
|
@ -344,5 +344,13 @@ class TestFiber < Test::Unit::TestCase
|
||||||
assert_equal("inner", s2)
|
assert_equal("inner", s2)
|
||||||
assert_equal(s1, $_, bug7678)
|
assert_equal(s1, $_, bug7678)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_new_symbol_proc
|
||||||
|
bug = '[ruby-core:80147] [Bug #13313]'
|
||||||
|
assert_ruby_status([], "#{<<-"begin;"}\n#{<<-'end;'}", bug)
|
||||||
|
begin;
|
||||||
|
exit("1" == Fiber.new(&:to_s).resume(1))
|
||||||
|
end;
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
16
thread.c
16
thread.c
|
@ -550,16 +550,28 @@ ruby_thread_init_stack(rb_thread_t *th)
|
||||||
native_thread_init_stack(th);
|
native_thread_init_stack(th);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const VALUE *
|
||||||
|
rb_vm_proc_local_ep(VALUE proc)
|
||||||
|
{
|
||||||
|
const VALUE *ep = vm_proc_ep(proc);
|
||||||
|
|
||||||
|
if (ep) {
|
||||||
|
return rb_vm_ep_local_ep(ep);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
thread_do_start(rb_thread_t *th, VALUE args)
|
thread_do_start(rb_thread_t *th, VALUE args)
|
||||||
{
|
{
|
||||||
native_set_thread_name(th);
|
native_set_thread_name(th);
|
||||||
if (!th->first_func) {
|
if (!th->first_func) {
|
||||||
const VALUE *ep = vm_proc_ep(th->first_proc);
|
|
||||||
rb_proc_t *proc;
|
rb_proc_t *proc;
|
||||||
GetProcPtr(th->first_proc, proc);
|
GetProcPtr(th->first_proc, proc);
|
||||||
th->errinfo = Qnil;
|
th->errinfo = Qnil;
|
||||||
th->root_lep = ep ? rb_vm_ep_local_ep(ep) : NULL;
|
th->root_lep = rb_vm_proc_local_ep(th->first_proc);
|
||||||
th->root_svar = Qfalse;
|
th->root_svar = Qfalse;
|
||||||
EXEC_EVENT_HOOK(th, RUBY_EVENT_THREAD_BEGIN, th->self, 0, 0, 0, Qundef);
|
EXEC_EVENT_HOOK(th, RUBY_EVENT_THREAD_BEGIN, th->self, 0, 0, 0, Qundef);
|
||||||
th->value = rb_vm_invoke_proc(th, proc,
|
th->value = rb_vm_invoke_proc(th, proc,
|
||||||
|
|
|
@ -1166,6 +1166,8 @@ VM_STACK_ENV_WRITE(const VALUE *ep, int index, VALUE v)
|
||||||
}
|
}
|
||||||
|
|
||||||
const VALUE *rb_vm_ep_local_ep(const VALUE *ep);
|
const VALUE *rb_vm_ep_local_ep(const VALUE *ep);
|
||||||
|
const VALUE *rb_vm_proc_local_ep(VALUE proc);
|
||||||
|
|
||||||
VALUE rb_vm_frame_block_handler(const rb_control_frame_t *cfp);
|
VALUE rb_vm_frame_block_handler(const rb_control_frame_t *cfp);
|
||||||
|
|
||||||
#define RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp) ((cfp)+1)
|
#define RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp) ((cfp)+1)
|
||||||
|
|
Loading…
Reference in a new issue