aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-07 06:36:07 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-07 06:36:07 +0000
commit9cfbbffb5f82449932aa137e85c2b9c04399a46a (patch)
tree106932cf119fee25c47aac14c0a4b563f1d3d13d
parent76e8dc03d1a4ae7fd706fca86009837f4dd76158 (diff)
downloadruby-9cfbbffb5f82449932aa137e85c2b9c04399a46a.tar.gz
Symptomatic treatment for `rb_thread_terminate_all` freeze
Under uncertain condition, `rb_thread_terminate_all` gets stuck. `make test-all TESTOPTS="test/ruby/test_gc.rb -n test_interrupt_in_finalizer` fails very rarely (only once every thousand runs). This IS a bug, but seems difficult to fix it soon. This commit makes `rb_thread_terminate_all` wake up every one second, instead of waiting forever, which mitigates the unuseful freeze. This is not an essential solution for the bug, though. I'll create a ticket with how to reproduce the original issue. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60694 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--thread.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/thread.c b/thread.c
index 3cbb97dd37..bfa903c6a4 100644
--- a/thread.c
+++ b/thread.c
@@ -476,6 +476,8 @@ rb_threadptr_unlock_all_locking_mutexes(rb_thread_t *th)
}
}
+static struct timeval double2timeval(double d);
+
void
rb_thread_terminate_all(void)
{
@@ -499,12 +501,13 @@ rb_thread_terminate_all(void)
terminate_all(vm, th);
while (vm_living_thread_num(vm) > 1) {
+ struct timeval tv = double2timeval(1.0);
/*
* Thread exiting routine in thread_start_func_2 notify
* me when the last sub-thread exit.
*/
sleeping = 1;
- native_sleep(th, 0);
+ native_sleep(th, &tv);
RUBY_VM_CHECK_INTS_BLOCKING(ec);
sleeping = 0;
}