diff options
author | Bill Holmes <bill.holmes@unity3d.com> | 2022-05-24 17:37:19 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-24 17:37:19 +0300 |
commit | 41d4eb187476f9f983a2a7ec6f851bac6cd5e44e (patch) | |
tree | ca3dca7132323f7d3788d94cc44aa5b00201bc60 | |
parent | 9b709ab7e7645e2560721b54027b57de62cc41eb (diff) |
Set app context to null on thread detach (#21482)
When a domain is unloaded, it is possible that an InternalThread
has a reference to an app context from the unloaded domain.
-rw-r--r-- | mono/metadata/domain.c | 1 | ||||
-rw-r--r-- | mono/metadata/threads.c | 2 |
2 files changed, 2 insertions, 1 deletions
diff --git a/mono/metadata/domain.c b/mono/metadata/domain.c index 6d455e4fa77..e3b0b73d8c8 100644 --- a/mono/metadata/domain.c +++ b/mono/metadata/domain.c @@ -931,6 +931,7 @@ void mono_domain_unset (void) { SET_APPDOMAIN (NULL); + SET_APPCONTEXT(NULL); } void diff --git a/mono/metadata/threads.c b/mono/metadata/threads.c index 9bfb9ed4d1e..3575168302c 100644 --- a/mono/metadata/threads.c +++ b/mono/metadata/threads.c @@ -1085,8 +1085,8 @@ mono_thread_detach_internal (MonoInternalThread *thread) /* There is no more any guarantee that `thread` is alive */ mono_memory_barrier (); + mono_domain_unset(); SET_CURRENT_OBJECT (NULL); - mono_domain_unset (); if (!mono_thread_info_try_get_internal_thread_gchandle (info, &gchandle)) g_error ("%s: failed to get gchandle, info = %p", __func__, info); |