File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -55,6 +55,8 @@ struct objspace {
5555 pthread_cond_t cond_world_started ;
5656 size_t start_the_world_count ;
5757
58+ pthread_mutex_t event_hook_mutex ;
59+
5860 struct {
5961 bool gc_thread_crashed ;
6062 char crash_msg [256 ];
@@ -354,9 +356,9 @@ rb_mmtk_call_obj_free(MMTk_ObjectReference object)
354356 struct objspace * objspace = rb_gc_get_objspace ();
355357
356358 if (RB_UNLIKELY (rb_gc_event_hook_required_p (RUBY_INTERNAL_EVENT_FREEOBJ ))) {
357- rb_gc_worker_thread_set_vm_context (& objspace -> vm_context );
359+ pthread_mutex_lock (& objspace -> event_hook_mutex );
358360 rb_gc_event_hook (obj , RUBY_INTERNAL_EVENT_FREEOBJ );
359- rb_gc_worker_thread_unset_vm_context (& objspace -> vm_context );
361+ pthread_mutex_unlock (& objspace -> event_hook_mutex );
360362 }
361363
362364 rb_gc_obj_free (objspace , obj );
@@ -599,6 +601,8 @@ rb_gc_impl_objspace_init(void *objspace_ptr)
599601 objspace -> mutex = (pthread_mutex_t )PTHREAD_MUTEX_INITIALIZER ;
600602 objspace -> cond_world_stopped = (pthread_cond_t )PTHREAD_COND_INITIALIZER ;
601603 objspace -> cond_world_started = (pthread_cond_t )PTHREAD_COND_INITIALIZER ;
604+
605+ objspace -> event_hook_mutex = (pthread_mutex_t )PTHREAD_MUTEX_INITIALIZER ;
602606}
603607
604608void
You can’t perform that action at this time.
0 commit comments