diff options
author | Matt Valentine-House <matt@eightbitraptor.com> | 2020-06-30 22:19:18 +0100 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2020-09-10 08:48:51 -0700 |
commit | ef22af4db0e38db406cfc46987cbe03582de2da0 (patch) | |
tree | ebee7c25afce4527d5c23dd0481143ad2d4b7223 /thread.c | |
parent | 867204c4a558f318be9d39da47298d5ccc85ff17 (diff) | |
download | ruby-ef22af4db0e38db406cfc46987cbe03582de2da0.tar.gz |
If the GC runs before the Mutex's are initialised then we get a crash in pthread_mutex_lock.
It is possible for GC to run during initialisation due to objects being allocated
Diffstat (limited to 'thread.c')
-rw-r--r-- | thread.c | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -5423,6 +5423,16 @@ rb_thread_backtrace_locations_m(int argc, VALUE *argv, VALUE thval) return rb_vm_thread_backtrace_locations(argc, argv, thval); } +void +Init_Thread_Mutex() +{ + rb_thread_t *th = GET_THREAD(); + + rb_native_mutex_initialize(&th->vm->waitpid_lock); + rb_native_mutex_initialize(&th->vm->workqueue_lock); + rb_native_mutex_initialize(&th->interrupt_lock); +} + /* * Document-class: ThreadError * @@ -5542,9 +5552,6 @@ Init_Thread(void) /* acquire global vm lock */ rb_global_vm_lock_t *gvl = rb_ractor_gvl(th->ractor); gvl_acquire(gvl, th); - rb_native_mutex_initialize(&th->vm->waitpid_lock); - rb_native_mutex_initialize(&th->vm->workqueue_lock); - rb_native_mutex_initialize(&th->interrupt_lock); th->pending_interrupt_queue = rb_ary_tmp_new(0); th->pending_interrupt_queue_checked = 0; |