Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix mono_alc_from_gchandle use field
  • Loading branch information
srxqds authored Nov 29, 2021
commit 9eb9381ab3c73bee2c3e9444fdabf9cb6780c335
18 changes: 13 additions & 5 deletions src/mono/mono/metadata/assembly-load-context.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,11 +424,19 @@ mono_alc_from_gchandle (MonoGCHandle alc_gchandle)
if (alc_gchandle == default_alc->gchandle)
return default_alc;

HANDLE_FUNCTION_ENTER ();
MonoManagedAssemblyLoadContextHandle managed_alc = MONO_HANDLE_CAST (MonoManagedAssemblyLoadContext, mono_gchandle_get_target_handle (alc_gchandle));
g_assert (!MONO_HANDLE_IS_NULL (managed_alc));
MonoAssemblyLoadContext *alc = MONO_HANDLE_GETVAL (managed_alc, native_assembly_load_context);
HANDLE_FUNCTION_RETURN_VAL (alc);
MONO_STATIC_POINTER_INIT (MonoClassField, resolve)

MonoClass *alc_class = mono_class_get_assembly_load_context_class ();
g_assert (alc_class);
resolve = mono_class_get_field_from_name (alc_class, "_nativeAssemblyLoadContext");

MONO_STATIC_POINTER_INIT_END (MonoClassField, resolve)

g_assert (resolve);

MonoAssemblyLoadContext *alc = NULL;
mono_field_get_value(mono_gchandle_get_target_internal(alc_gchandle), resolve, &alc);
return alc;
}

MonoGCHandle
Expand Down