From a2ba50d97119044ddc0a847a89fc5fddcd6e0d83 Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 31 Jan 2011 12:40:19 +0000 Subject: [PATCH] * thread.c (thread_start_func_2): check deadlock condition before release thread stack. fix memory violation when deadlock detected. reported by Max Aller. [Bug #4009] [ruby-core:32982] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30743 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ thread.c | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index f2ce6678d3..272150d919 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Mon Jan 31 21:32:44 2011 CHIKANAGA Tomoyuki + + * thread.c (thread_start_func_2): check deadlock condition before + release thread stack. fix memory violation when deadlock detected. + reported by Max Aller. [Bug #4009] [ruby-core:32982] + Mon Jan 31 14:45:47 2011 Yuki Sonoda (Yugui) * lib/irb/locale.rb (IRB::Locale::#search_file): diff --git a/thread.c b/thread.c index 69fc299fcd..b1a802b89c 100644 --- a/thread.c +++ b/thread.c @@ -524,13 +524,14 @@ thread_start_func_2(rb_thread_t *th, VALUE *stack_start, VALUE *register_stack_s join_th = join_th->join_list_next; } + thread_unlock_all_locking_mutexes(th); + if (th != main_th) rb_check_deadlock(th->vm); + if (!th->root_fiber) { rb_thread_recycle_stack_release(th->stack); th->stack = 0; } } - thread_unlock_all_locking_mutexes(th); - if (th != main_th) rb_check_deadlock(th->vm); if (th->vm->main_thread == th) { ruby_cleanup(state); }