From: Jay Krell Date: Fri, 13 Dec 2019 11:27:39 +0000 (-0800) Subject: Fix on-demand initialize race conditions [custom-attrs.c] (mono/mono#18159) X-Git-Tag: submit/tizen/20210909.063632~10331^2~5^2~87 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=db3af38a8bf93da38072c53cb7f8d64d796d2b8a;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Fix on-demand initialize race conditions [custom-attrs.c] (mono/mono#18159) Commit migrated from https://github.com/mono/mono/commit/64ad6460664615586883ac9ea5eb2ec478e85f18 --- diff --git a/src/mono/mono/metadata/custom-attrs.c b/src/mono/mono/metadata/custom-attrs.c index 6e6ae90..3e7e458 100644 --- a/src/mono/mono/metadata/custom-attrs.c +++ b/src/mono/mono/metadata/custom-attrs.c @@ -617,17 +617,18 @@ load_cattr_value_boxed (MonoDomain *domain, MonoImage *image, MonoType *t, const static MonoObject* create_cattr_typed_arg (MonoType *t, MonoObject *val, MonoError *error) { - static MonoMethod *ctor; MonoObject *retval; void *params [2], *unboxed; error_init (error); - if (!ctor) { + MONO_STATIC_POINTER_INIT (MonoMethod, ctor) + ctor = mono_class_get_method_from_name_checked (mono_class_get_custom_attribute_typed_argument_class (), ".ctor", 2, 0, error); mono_error_assert_ok (error); - } - + + MONO_STATIC_POINTER_INIT_END (MonoMethod, ctor) + params [0] = mono_type_get_object_checked (mono_domain_get (), t, error); return_val_if_nok (error, NULL); @@ -645,16 +646,17 @@ create_cattr_typed_arg (MonoType *t, MonoObject *val, MonoError *error) static MonoObject* create_cattr_named_arg (void *minfo, MonoObject *typedarg, MonoError *error) { - static MonoMethod *ctor; MonoObject *retval; void *unboxed, *params [2]; error_init (error); - if (!ctor) { + MONO_STATIC_POINTER_INIT (MonoMethod, ctor) + ctor = mono_class_get_method_from_name_checked (mono_class_get_custom_attribute_named_argument_class (), ".ctor", 2, 0, error); mono_error_assert_ok (error); - } + + MONO_STATIC_POINTER_INIT_END (MonoMethod, ctor) params [0] = minfo; params [1] = typedarg;