From 8ecd3b7114d6c0b81c0165dd0defa8f3df261d0b Mon Sep 17 00:00:00 2001 From: kosaki Date: Sun, 14 Jun 2015 22:52:01 +0000 Subject: * thread.c (thread_start_func_2): don't interrupt when last thread exit unless main thread is already exited. Otherwise main thread could be wrongly interrupted when it uses rb_thread_call_without_gvl(). Patch by Takehiro Kubo. [Bug #11237][ruby-dev:49044][GH-898] * test/-ext-/gvl/test_last_thread.rb: new test for the above fix. * ext/-test-/gvl/call_without_gvl/call_without_gvl.c: new ext for the above test. * ext/-test-/gvl/call_without_gvl/extconf.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50900 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/-ext-/gvl/test_last_thread.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 test/-ext-/gvl/test_last_thread.rb (limited to 'test/-ext-/gvl') diff --git a/test/-ext-/gvl/test_last_thread.rb b/test/-ext-/gvl/test_last_thread.rb new file mode 100644 index 0000000000..df25165b4b --- /dev/null +++ b/test/-ext-/gvl/test_last_thread.rb @@ -0,0 +1,22 @@ +class TestLastThread < Test::Unit::TestCase + + # [Bug #11237] + def test_last_thread + + assert_separately([], <<-"end;") #do + require '-test-/gvl/call_without_gvl' + + Thread.new { + sleep 0.2 + } + + t0 = Time.now + Thread.current.__runnable_sleep__ 1 + t1 = Time.now + t = t1 - t0 + + assert_operator(t, :>=, 1) + end; + end +end + -- cgit v1.2.3