mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
867204c4a5
commit
ef22af4db0
Notes:
git
2020-09-11 00:49:32 +09:00
2 changed files with 11 additions and 3 deletions
1
inits.c
1
inits.c
|
@ -20,6 +20,7 @@ static void Init_builtin_prelude(void);
|
|||
void
|
||||
rb_call_inits(void)
|
||||
{
|
||||
CALL(Thread_Mutex);
|
||||
#if USE_TRANSIENT_HEAP
|
||||
CALL(TransientHeap);
|
||||
#endif
|
||||
|
|
13
thread.c
13
thread.c
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue