summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-15 07:27:04 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-15 07:27:04 +0000
commitf5183827dc37e2da8d78e364dd700049461ad8ef (patch)
tree157caf5954fe280a74a6196cc3c64a97de21441d /thread.c
parent57b0489cdba76c008af22a2ba931fe8232d4c008 (diff)
thread.c: fix deadlock
* thread.c (thread_join_sleep): the target thread may exit during `RUBY_VM_CHECK_INTS_BLOCKING`, but `sleep_forever` does not consider the condition change to wait. [ruby-core:84248] [Bug #14181] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61274 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/thread.c b/thread.c
index baa50ea388..cc62ea3905 100644
--- a/thread.c
+++ b/thread.c
@@ -883,7 +883,13 @@ thread_join_sleep(VALUE arg)
while (target_th->status != THREAD_KILLED) {
if (forever) {
- sleep_forever(th, TRUE, FALSE);
+ th->status = THREAD_STOPPED_FOREVER;
+ th->vm->sleeper++;
+ rb_check_deadlock(th->vm);
+ native_sleep(th, 0);
+ th->vm->sleeper--;
+ RUBY_VM_CHECK_INTS_BLOCKING(th->ec);
+ th->status = THREAD_RUNNABLE;
}
else {
double now = timeofday();