summaryrefslogtreecommitdiff
path: root/thread_pthread.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-07-30 05:51:01 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-07-30 05:51:01 +0000
commit95cae748171f4754b97f4ba54da2ae62a8d484fd (patch)
treedd45648b1503ef7bd5257fc2d26cfe36b4978c91 /thread_pthread.c
parent4514362948fdb914c6138b12d961d92e9c0fee6c (diff)
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
Diffstat (limited to 'thread_pthread.c')
-rw-r--r--thread_pthread.c13
1 files changed, 10 insertions, 3 deletions
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();
}