summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cont.c2
-rw-r--r--test/ruby/test_fiber.rb8
-rw-r--r--test/ruby/test_thread.rb8
-rw-r--r--thread.c53
-rw-r--r--version.h2
-rw-r--r--vm_core.h2
6 files changed, 55 insertions, 20 deletions
diff --git a/cont.c b/cont.c
index 6760cb3504..ab4f2bc830 100644
--- a/cont.c
+++ b/cont.c
@@ -1277,7 +1277,7 @@ rb_fiber_start(void)
argv = (argc = cont->argc) > 1 ? RARRAY_CONST_PTR(args) : &args;
cont->value = 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;
fib->status = RUNNING;
diff --git a/test/ruby/test_fiber.rb b/test/ruby/test_fiber.rb
index d1d15828fc..ffcb02ce51 100644
--- a/test/ruby/test_fiber.rb
+++ b/test/ruby/test_fiber.rb
@@ -344,5 +344,13 @@ class TestFiber < Test::Unit::TestCase
assert_equal("inner", s2)
assert_equal(s1, $_, bug7678)
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
diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb
index d7b5dadf81..43aae09d7d 100644
--- a/test/ruby/test_thread.rb
+++ b/test/ruby/test_thread.rb
@@ -176,6 +176,14 @@ class TestThread < Test::Unit::TestCase
t2.kill if t2
end
+ def test_new_symbol_proc
+ bug = '[ruby-core:80147] [Bug #13313]'
+ assert_ruby_status([], "#{<<-"begin;"}\n#{<<-'end;'}", bug)
+ begin;
+ exit("1" == Thread.start(1, &:to_s).value)
+ end;
+ end
+
def test_join
t = Thread.new { sleep }
assert_nil(t.join(0.05))
diff --git a/thread.c b/thread.c
index e080e161b2..7391cf96d2 100644
--- a/thread.c
+++ b/thread.c
@@ -550,12 +550,45 @@ ruby_thread_init_stack(rb_thread_t *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
+thread_do_start(rb_thread_t *th, VALUE args)
+{
+ native_set_thread_name(th);
+ if (!th->first_func) {
+ rb_proc_t *proc;
+ GetProcPtr(th->first_proc, proc);
+ th->errinfo = Qnil;
+ th->root_lep = rb_vm_proc_local_ep(th->first_proc);
+ th->root_svar = Qfalse;
+ EXEC_EVENT_HOOK(th, RUBY_EVENT_THREAD_BEGIN, th->self, 0, 0, 0, Qundef);
+ th->value = rb_vm_invoke_proc(th, proc,
+ (int)RARRAY_LEN(args), RARRAY_CONST_PTR(args),
+ VM_BLOCK_HANDLER_NONE);
+ EXEC_EVENT_HOOK(th, RUBY_EVENT_THREAD_END, th->self, 0, 0, 0, Qundef);
+ }
+ else {
+ th->value = (*th->first_func)((void *)args);
+ }
+}
+
static int
thread_start_func_2(rb_thread_t *th, VALUE *stack_start, VALUE *register_stack_start)
{
int state;
VALUE args = th->first_args;
- rb_proc_t *proc;
rb_thread_list_t *join_list;
rb_thread_t *main_th;
VALUE errinfo = Qnil;
@@ -583,23 +616,7 @@ thread_start_func_2(rb_thread_t *th, VALUE *stack_start, VALUE *register_stack_s
TH_PUSH_TAG(th);
if ((state = EXEC_TAG()) == 0) {
- SAVE_ROOT_JMPBUF(th, {
- native_set_thread_name(th);
- if (!th->first_func) {
- GetProcPtr(th->first_proc, proc);
- th->errinfo = Qnil;
- th->root_lep = rb_vm_ep_local_ep(vm_proc_ep(th->first_proc));
- th->root_svar = Qfalse;
- EXEC_EVENT_HOOK(th, RUBY_EVENT_THREAD_BEGIN, th->self, 0, 0, 0, Qundef);
- th->value = rb_vm_invoke_proc(th, proc,
- (int)RARRAY_LEN(args), RARRAY_CONST_PTR(args),
- VM_BLOCK_HANDLER_NONE);
- EXEC_EVENT_HOOK(th, RUBY_EVENT_THREAD_END, th->self, 0, 0, 0, Qundef);
- }
- else {
- th->value = (*th->first_func)((void *)args);
- }
- });
+ SAVE_ROOT_JMPBUF(th, thread_do_start(th, args));
}
else {
errinfo = th->errinfo;
diff --git a/version.h b/version.h
index 2299a31817..eb3d8b91b9 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.4.0"
#define RUBY_RELEASE_DATE "2017-03-17"
-#define RUBY_PATCHLEVEL 104
+#define RUBY_PATCHLEVEL 105
#define RUBY_RELEASE_YEAR 2017
#define RUBY_RELEASE_MONTH 3
diff --git a/vm_core.h b/vm_core.h
index ff5ff90a56..d0385d219f 100644
--- a/vm_core.h
+++ b/vm_core.h
@@ -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_proc_local_ep(VALUE proc);
+
VALUE rb_vm_frame_block_handler(const rb_control_frame_t *cfp);
#define RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp) ((cfp)+1)