ruby-changes:45896
From: nobu <ko1@a...>
Date: Tue, 14 Mar 2017 14:54:39 +0900 (JST)
Subject: [ruby-changes:45896] nobu:r57969 (trunk): thread.c: Thread.start with Symbol
nobu 2017-03-14 14:54:35 +0900 (Tue, 14 Mar 2017) New Revision: 57969 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57969 Log: thread.c: Thread.start with Symbol * thread.c (thread_do_start): fix segfault at start with Symbol. proc created by Symbol#to_proc does not have environment unless using refinements. [ruby-core:80147] [Bug #13313] Modified files: trunk/test/ruby/test_thread.rb trunk/thread.c Index: test/ruby/test_thread.rb =================================================================== --- test/ruby/test_thread.rb (revision 57968) +++ test/ruby/test_thread.rb (revision 57969) @@ -176,6 +176,14 @@ class TestThread < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_thread.rb#L176 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)) Index: thread.c =================================================================== --- thread.c (revision 57968) +++ thread.c (revision 57969) @@ -555,10 +555,11 @@ thread_do_start(rb_thread_t *th, VALUE a https://github.com/ruby/ruby/blob/trunk/thread.c#L555 { native_set_thread_name(th); if (!th->first_func) { + const VALUE *ep = vm_proc_ep(th->first_proc); rb_proc_t *proc; GetProcPtr(th->first_proc, proc); th->errinfo = Qnil; - th->root_lep = rb_vm_ep_local_ep(vm_proc_ep(th->first_proc)); + th->root_lep = ep ? rb_vm_ep_local_ep(ep) : NULL; 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, -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/