Skip to content

Commit

Permalink
Fix on-demand initialization race conditions [sgen]. (mono/mono#18170)
Browse files Browse the repository at this point in the history
Fix on-demand initialization race conditions [sgen].

Extracted from mono/mono#18150 which reviewer said was too big.


Commit migrated from mono/mono@9cefdf5
  • Loading branch information
jaykrell authored and monojenkins committed Dec 13, 2019
1 parent 3eec642 commit 65b5d9d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/mono/mono/metadata/sgen-toggleref.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,14 @@ mono_gc_toggleref_register_callback (MonoToggleRefStatus (*proccess_toggleref) (
static MonoToggleRefStatus
test_toggleref_callback (MonoObject *obj)
{
static MonoClassField *mono_toggleref_test_field;
MonoToggleRefStatus status = MONO_TOGGLE_REF_DROP;

if (!mono_toggleref_test_field) {
MONO_STATIC_POINTER_INIT (MonoClassField, mono_toggleref_test_field)

mono_toggleref_test_field = mono_class_get_field_from_name_full (mono_object_class (obj), "__test", NULL);
g_assert (mono_toggleref_test_field);
}

MONO_STATIC_POINTER_INIT_END (MonoClassField, mono_toggleref_test_field)

/* In coop mode, important to not call a helper that will pin obj! */
mono_field_get_value_internal (obj, mono_toggleref_test_field, &status);
Expand Down

0 comments on commit 65b5d9d

Please sign in to comment.