Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormonojenkins <jo.shields+jenkins@xamarin.com>2020-01-31 01:12:54 +0300
committerGitHub <noreply@github.com>2020-01-31 01:12:54 +0300
commit1317cf06da06682419f8f4b0c9810ad5d5d3ac3a (patch)
tree9ef0b06bf7ffaa4693b9370dedfcf47c2a0ab65d
parent04c01efd4997d1f58ecdc0310932df2f4eb84fe5 (diff)
[aot] Fix some races if GOT entries are already set. (#18636)
decode_patch_info () would not decode patches if their corresponding GOT entry was already set, causing half initialized MonoJumpInfo entries to be returned to callers. Set the type of the MonoJumpInfo entry to MONO_PATCH_INFO_NONE in these cases, and have the callers handle it. Co-authored-by: Zoltan Varga <vargaz@gmail.com>
-rw-r--r--mono/mini/aot-runtime.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/mono/mini/aot-runtime.c b/mono/mini/aot-runtime.c
index 74ae3053f77..ca8747e78ab 100644
--- a/mono/mini/aot-runtime.c
+++ b/mono/mini/aot-runtime.c
@@ -2043,6 +2043,7 @@ init_amodule_got (MonoAotModule *amodule)
}
} else if (ji->type == MONO_PATCH_INFO_AOT_MODULE) {
amodule->shared_got [i] = amodule;
+ } else if (ji->type == MONO_PATCH_INFO_NONE) {
} else {
amodule->shared_got [i] = mono_resolve_patch_target (NULL, mono_get_root_domain (), NULL, ji, FALSE, error);
mono_error_assert_ok (error);
@@ -4031,7 +4032,8 @@ decode_patch (MonoAotModule *aot_module, MonoMemPool *mp, MonoJumpInfo *ji, guin
* decode_patches:
*
* Decode a list of patches identified by the got offsets in GOT_OFFSETS. Return an array of
- * MonoJumpInfo structures allocated from MP.
+ * MonoJumpInfo structures allocated from MP. GOT entries already loaded have their
+ * ji->type set to MONO_PATCH_INFO_NONE.
*/
static MonoJumpInfo*
decode_patches (MonoAotModule *amodule, MonoMemPool *mp, int n_patches, gboolean llvm, guint32 *got_offsets)
@@ -4061,6 +4063,7 @@ decode_patches (MonoAotModule *amodule, MonoMemPool *mp, int n_patches, gboolean
/* See load_method () for SFLDA */
if (got && got [got_offsets [i]] && ji->type != MONO_PATCH_INFO_SFLDA) {
/* Already loaded */
+ ji->type = MONO_PATCH_INFO_NONE;
} else {
res = decode_patch (amodule, mp, ji, p, &p);
if (!res)
@@ -4597,7 +4600,8 @@ init_method (MonoAotModule *amodule, guint32 method_index, MonoMethod *method, M
* been initialized by load_method () for a static cctor before the cctor has
* finished executing (#23242).
*/
- if (!got [got_slots [pindex]] || ji->type == MONO_PATCH_INFO_SFLDA) {
+ if (ji->type == MONO_PATCH_INFO_NONE) {
+ } else if (!got [got_slots [pindex]] || ji->type == MONO_PATCH_INFO_SFLDA) {
/* In llvm-only made, we might encounter shared methods */
if (mono_llvm_only && ji->type == MONO_PATCH_INFO_METHOD && mono_method_check_context_used (ji->data.method)) {
g_assert (context);
@@ -5347,7 +5351,6 @@ load_function_full (MonoAotModule *amodule, const char *name, MonoTrampInfo **ou
target = mono_create_specific_trampoline (GUINT_TO_POINTER (ji->data.uindex), MONO_TRAMPOLINE_RGCTX_LAZY_FETCH, mono_get_root_domain (), NULL);
target = mono_create_ftnptr_malloc ((guint8 *)target);
} else if (ji->type == MONO_PATCH_INFO_JIT_ICALL_ADDR) {
-
const MonoJitICallId jit_icall_id = (MonoJitICallId)ji->data.jit_icall_id;
switch (jit_icall_id) {
@@ -5394,7 +5397,8 @@ load_function_full (MonoAotModule *amodule, const char *name, MonoTrampInfo **ou
g_assert (target);
}
- amodule->got [got_slots [pindex]] = target;
+ if (ji->type != MONO_PATCH_INFO_NONE)
+ amodule->got [got_slots [pindex]] = target;
}
g_free (got_slots);