summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cont.c5
-rw-r--r--test/ruby/test_continuation.rb17
2 files changed, 17 insertions, 5 deletions
diff --git a/cont.c b/cont.c
index 70bc4ef7f3..142713ad84 100644
--- a/cont.c
+++ b/cont.c
@@ -778,6 +778,10 @@ cont_restore_thread(rb_context_t *cont)
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)
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);
}
diff --git a/test/ruby/test_continuation.rb b/test/ruby/test_continuation.rb
index a06ac98c8c..8c62d20840 100644
--- a/test/ruby/test_continuation.rb
+++ b/test/ruby/test_continuation.rb
@@ -88,11 +88,16 @@ class TestContinuation < Test::Unit::TestCase
@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::TestCase
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::TestCase
@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 }