From dc29d6c4b60812cbc57ce9794e57187e0ecf2b21 Mon Sep 17 00:00:00 2001 From: Jay Krell Date: Thu, 12 Dec 2019 14:55:33 -0800 Subject: [PATCH] Fix on-demand initialization race conditions [sre.c]. (mono/mono#18164) Fix on-demand initialization race conditions [sre.c]. Extracted from https://github.com/mono/mono/pull/18150 which reviewer said was too big. Commit migrated from https://github.com/mono/mono/commit/620d7cf84d026417c0390bcef0b50acda6e0f40d --- src/mono/mono/metadata/sre.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/mono/mono/metadata/sre.c b/src/mono/mono/metadata/sre.c index be32563..2fe2fac 100644 --- a/src/mono/mono/metadata/sre.c +++ b/src/mono/mono/metadata/sre.c @@ -1650,15 +1650,16 @@ mono_is_sre_ctor_on_tb_inst (MonoClass *klass) static MonoReflectionTypeHandle mono_reflection_type_get_underlying_system_type (MonoReflectionTypeHandle t, MonoError *error) { - static MonoMethod *method_get_underlying_system_type = NULL; HANDLE_FUNCTION_ENTER (); error_init (error); - if (!method_get_underlying_system_type) { + MONO_STATIC_POINTER_INIT (MonoMethod, method_get_underlying_system_type) + method_get_underlying_system_type = mono_class_get_method_from_name_checked (mono_defaults.systemtype_class, "get_UnderlyingSystemType", 0, 0, error); mono_error_assert_ok (error); - } + + MONO_STATIC_POINTER_INIT_END (MonoMethod, method_get_underlying_system_type) MonoReflectionTypeHandle rt = MONO_HANDLE_NEW (MonoReflectionType, NULL); -- 2.7.4