Skip to content

Commit a102a35

Browse files
[2020-02] [mono][loader] Set status on success; avoid mmap on Android (#21610)
Manual backport of dotnet/runtime#80949 to mono/mono Emebedders that call `mono_assembly_load_from_full` may observe a non-NULL return value and an uninitialized MonoImageOpenStatus, which may lead to incorrect diagnostics in code like: ``` MonoImageOpenStatus status; MonoAssembly *assembly = mono_assembly_load_from_full (image, name, status, refonly); if (!assembly || status != MONO_IMAGE_OK) { fprintf(stderr, "Failure due to: %s\n", mono_image_strerror (status)); abort(); } ``` Which will print `Failure due to: Internal error` Avoid an mmap that will fail since Android uses a custom loader and the assemblies aren't on disk Co-authored-by: Aleksey Kliger <alklig@microsoft.com>
1 parent 74f85c2 commit a102a35

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

mono/metadata/assembly.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3171,6 +3171,8 @@ mono_assembly_request_load_from (MonoImage *image, const char *fname,
31713171
mono_image_fixup_vtable (image);
31723172
#endif
31733173

3174+
*status = MONO_IMAGE_OK;
3175+
31743176
mono_assembly_invoke_load_hook_internal (req->alc, ass);
31753177

31763178
MONO_PROFILER_RAISE (assembly_loaded, (ass));

mono/metadata/image.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,7 @@ static void
10671067
mono_image_load_time_date_stamp (MonoImage *image)
10681068
{
10691069
image->time_date_stamp = 0;
1070-
#ifndef HOST_WIN32
1070+
#if !defined (HOST_WIN32) && !defined (HOST_ANDROID)
10711071
if (!image->filename)
10721072
return;
10731073

0 commit comments

Comments
 (0)