From 95cae748171f4754b97f4ba54da2ae62a8d484fd Mon Sep 17 00:00:00 2001 From: normal Date: Mon, 30 Jul 2018 05:51:01 +0000 Subject: thread_pthread.c (gvl_destroy): make no-op on GVL bits It's possible for another thread to take vm->gvl.lock during gvl_release at the end of thread_start_func_2 during VM shutdown, at least. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64114 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- thread_pthread.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'thread_pthread.c') diff --git a/thread_pthread.c b/thread_pthread.c index 1ab676bc89..fdd719abbf 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -208,9 +208,16 @@ gvl_init(rb_vm_t *vm) static void gvl_destroy(rb_vm_t *vm) { - rb_native_cond_destroy(&vm->gvl.switch_wait_cond); - rb_native_cond_destroy(&vm->gvl.switch_cond); - rb_native_mutex_destroy(&vm->gvl.lock); + /* + * only called once at VM shutdown (not atfork), another thread + * may still grab vm->gvl.lock when calling gvl_release at + * the end of thread_start_func_2 + */ + if (0) { + rb_native_cond_destroy(&vm->gvl.switch_wait_cond); + rb_native_cond_destroy(&vm->gvl.switch_cond); + rb_native_mutex_destroy(&vm->gvl.lock); + } clear_thread_cache_altstack(); } -- cgit v1.2.3