From a2950369bd8a5866092f6badf59b0811653a6092 Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Sat, 19 Dec 2020 06:38:58 +0900 Subject: TracePoint.new(&block) should be ractor-local TracePoint should be ractor-local because the Proc can violate the Ractor-safe. --- bootstraptest/test_ractor.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'bootstraptest') diff --git a/bootstraptest/test_ractor.rb b/bootstraptest/test_ractor.rb index 797ad0a3ee..a853e91416 100644 --- a/bootstraptest/test_ractor.rb +++ b/bootstraptest/test_ractor.rb @@ -1199,6 +1199,19 @@ assert_equal '[false, false, true, true]', %q{ r } +# TracePoint with normal Proc should be Ractor local +assert_equal '[4, 8]', %q{ + rs = [] + TracePoint.new(:line){|tp| rs << tp.lineno if tp.path == __FILE__}.enable do + Ractor.new{ # line 4 + a = 1 + b = 2 + }.take + c = 3 # line 8 + end + rs +} + # Ractor deep copies frozen objects (ary) assert_equal '[true, false]', %q{ Ractor.new([[]].freeze) { |ary| -- cgit v1.2.3