From dfb3605bbee9c3cfbc1c354594c367472f29cb35 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Wed, 28 Oct 2020 15:27:00 -0700 Subject: Add Thread.ignore_deadlock accessor Setting this to true disables the deadlock detector. It should only be used in cases where the deadlock could be broken via some external means, such as via a signal. Now that $SAFE is no longer used, replace the safe_level_ VM flag with ignore_deadlock for storing the setting. Fixes [Bug #13768] --- test/ruby/test_thread.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test') diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb index 30a3cc784e..0af7a37cf8 100644 --- a/test/ruby/test_thread.rb +++ b/test/ruby/test_thread.rb @@ -490,6 +490,19 @@ class TestThread < Test::Unit::TestCase end; end + def test_ignore_deadlock + if /mswin|mingw/ =~ RUBY_PLATFORM + skip "can't trap a signal from another process on Windows" + end + assert_in_out_err([], <<-INPUT, %w(false :sig), [], :signal=>:INT, timeout: 1, timeout_error: nil) + p Thread.ignore_deadlock + q = Queue.new + trap(:INT){q.push :sig} + Thread.ignore_deadlock = true + p q.pop + INPUT + end + def test_status_and_stop_p a = ::Thread.new { Thread.current.report_on_exception = false -- cgit v1.2.3