ruby-changes:53789
From: ko1 <ko1@a...>
Date: Tue, 27 Nov 2018 04:59:14 +0900 (JST)
Subject: [ruby-changes:53789] ko1:r66007 (trunk): Give up support for cross-callcc set_trace_func.
ko1 2018-11-27 04:59:08 +0900 (Tue, 27 Nov 2018) New Revision: 66007 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=66007 Log: Give up support for cross-callcc set_trace_func. * cont.c (cont_restore_thread): cause error if trace-status is changed. Modified files: trunk/cont.c trunk/test/ruby/test_continuation.rb Index: cont.c =================================================================== --- cont.c (revision 66006) +++ cont.c (revision 66007) @@ -778,6 +778,10 @@ cont_restore_thread(rb_context_t *cont) https://github.com/ruby/ruby/blob/trunk/cont.c#L778 ec_switch(th, fib); } + if (th->ec->trace_arg != sec->trace_arg) { + rb_raise(rb_eRuntimeError, "can't call across trace_func"); + } + /* copy vm stack */ #ifdef CAPTURE_JUST_VALID_VM_STACK MEMCPY(th->ec->vm_stack, @@ -799,7 +803,6 @@ cont_restore_thread(rb_context_t *cont) https://github.com/ruby/ruby/blob/trunk/cont.c#L803 th->ec->root_svar = sec->root_svar; th->ec->ensure_list = sec->ensure_list; th->ec->errinfo = sec->errinfo; - th->ec->trace_arg = sec->trace_arg; VM_ASSERT(th->ec->vm_stack != NULL); } Index: test/ruby/test_continuation.rb =================================================================== --- test/ruby/test_continuation.rb (revision 66006) +++ test/ruby/test_continuation.rb (revision 66007) @@ -88,11 +88,16 @@ class TestContinuation < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/ruby/test_continuation.rb#L88 @memo += 1 c = cont cont = nil - c.call(nil) + begin + c.call(nil) + rescue RuntimeError + set_trace_func(nil) + end end end end cont = callcc { |cc| cc } + if cont set_trace_func(func) else @@ -100,12 +105,12 @@ class TestContinuation < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/ruby/test_continuation.rb#L105 end end - def test_tracing_with_set_trace_func + def _test_tracing_with_set_trace_func @memo = 0 tracing_with_set_trace_func tracing_with_set_trace_func tracing_with_set_trace_func - assert_equal 3, @memo + assert_equal 0, @memo end def tracing_with_thread_set_trace_func @@ -115,7 +120,11 @@ class TestContinuation < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/ruby/test_continuation.rb#L120 @memo += 1 c = cont cont = nil - c.call(nil) + begin + c.call(nil) + rescue RuntimeError + Thread.current.set_trace_func(nil) + end end end cont = callcc { |cc| cc } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/