From 3e00e877295947e274ca2cb2ae6e3a03b0329c7b Mon Sep 17 00:00:00 2001 From: Matous Kozak Date: Tue, 6 Aug 2024 17:57:35 +0200 Subject: [PATCH 1/2] mark AOT module unusable if no version found --- src/mono/mono/mini/aot-runtime.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/mono/mono/mini/aot-runtime.c b/src/mono/mono/mini/aot-runtime.c index 2c7d6084373c47..0d8c332e296aa2 100644 --- a/src/mono/mono/mini/aot-runtime.c +++ b/src/mono/mono/mini/aot-runtime.c @@ -2102,15 +2102,13 @@ load_aot_module (MonoAssemblyLoadContext *alc, MonoAssembly *assembly, gpointer find_symbol (sofile, globals, "mono_aot_file_info", (gpointer*)&info); } - // Copy aotid to MonoImage - memcpy(&assembly->image->aotid, info->aotid, 16); - if (version_symbol) { /* Old file format */ version = atoi (version_symbol); - } else { - g_assert (info); + } else if (info) { version = info->version; + } else { + version = -1; } if (version != MONO_AOT_FILE_VERSION) { @@ -2120,6 +2118,9 @@ load_aot_module (MonoAssemblyLoadContext *alc, MonoAssembly *assembly, gpointer guint8 *blob; void *handle; + // Copy aotid to MonoImage + memcpy(&assembly->image->aotid, info->aotid, 16); + if (info->flags & MONO_AOT_FILE_FLAG_SEPARATE_DATA) { aot_data = open_aot_data (assembly, info, &handle); From cf141d3d54b19a221f929739726e99431f6a4424 Mon Sep 17 00:00:00 2001 From: Matous Kozak <55735845+matouskozak@users.noreply.github.com> Date: Tue, 6 Aug 2024 21:13:50 +0200 Subject: [PATCH 2/2] Update src/mono/mono/mini/aot-runtime.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Aleksey Kliger (λgeek) --- src/mono/mono/mini/aot-runtime.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mono/mono/mini/aot-runtime.c b/src/mono/mono/mini/aot-runtime.c index 0d8c332e296aa2..113984590689b8 100644 --- a/src/mono/mono/mini/aot-runtime.c +++ b/src/mono/mono/mini/aot-runtime.c @@ -2118,6 +2118,8 @@ load_aot_module (MonoAssemblyLoadContext *alc, MonoAssembly *assembly, gpointer guint8 *blob; void *handle; + g_assert (info); + // Copy aotid to MonoImage memcpy(&assembly->image->aotid, info->aotid, 16);