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:
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>2022-05-24 18:37:52 +0300
committerGitHub <noreply@github.com>2022-05-24 18:37:52 +0300
commitf354099a6b61418a78717578f939deadb30df848 (patch)
treea0b5be649b6f5fb717e2d71e91831d42d53fe1eb
parent6c7e72dd8e0a0986f197d1bb23f623a70ad87396 (diff)
Set app context to null on thread detach (#21489)mono-6.12.0.181
When a domain is unloaded, it is possible that an InternalThread has a reference to an app context from the unloaded domain. Co-authored-by: Bill Holmes <bill.holmes@unity3d.com>
-rw-r--r--mono/metadata/domain.c1
-rw-r--r--mono/metadata/threads.c2
2 files changed, 2 insertions, 1 deletions
diff --git a/mono/metadata/domain.c b/mono/metadata/domain.c
index 98214f13a61..cef0fa5d046 100644
--- a/mono/metadata/domain.c
+++ b/mono/metadata/domain.c
@@ -961,6 +961,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 5354a51b9e7..8d6753f2e01 100644
--- a/mono/metadata/threads.c
+++ b/mono/metadata/threads.c
@@ -1080,8 +1080,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);