File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -39,6 +39,8 @@ struct objspace {
3939 pthread_cond_t cond_world_started ;
4040 size_t start_the_world_count ;
4141
42+ pthread_mutex_t event_hook_mutex ;
43+
4244 struct {
4345 bool gc_thread_crashed ;
4446 char crash_msg [256 ];
@@ -338,9 +340,9 @@ rb_mmtk_call_obj_free(MMTk_ObjectReference object)
338340 struct objspace * objspace = rb_gc_get_objspace ();
339341
340342 if (RB_UNLIKELY (rb_gc_event_hook_required_p (RUBY_INTERNAL_EVENT_FREEOBJ ))) {
341- rb_gc_worker_thread_set_vm_context (& objspace -> vm_context );
343+ pthread_mutex_lock (& objspace -> event_hook_mutex );
342344 rb_gc_event_hook (obj , RUBY_INTERNAL_EVENT_FREEOBJ );
343- rb_gc_worker_thread_unset_vm_context (& objspace -> vm_context );
345+ pthread_mutex_unlock (& objspace -> event_hook_mutex );
344346 }
345347
346348 rb_gc_obj_free (objspace , obj );
@@ -579,6 +581,8 @@ rb_gc_impl_objspace_init(void *objspace_ptr)
579581 objspace -> mutex = (pthread_mutex_t )PTHREAD_MUTEX_INITIALIZER ;
580582 objspace -> cond_world_stopped = (pthread_cond_t )PTHREAD_COND_INITIALIZER ;
581583 objspace -> cond_world_started = (pthread_cond_t )PTHREAD_COND_INITIALIZER ;
584+
585+ objspace -> event_hook_mutex = (pthread_mutex_t )PTHREAD_MUTEX_INITIALIZER ;
582586}
583587
584588void
You can’t perform that action at this time.
0 commit comments