Skip to content

Commit f354099

Browse files
Set app context to null on thread detach (#21489)
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 <[email protected]>
1 parent 6c7e72d commit f354099

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

‎mono/metadata/domain.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,7 @@ void
961961
mono_domain_unset (void)
962962
{
963963
SET_APPDOMAIN (NULL);
964+
SET_APPCONTEXT(NULL);
964965
}
965966

966967
void

‎mono/metadata/threads.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1080,8 +1080,8 @@ mono_thread_detach_internal (MonoInternalThread *thread)
10801080
/* There is no more any guarantee that `thread` is alive */
10811081
mono_memory_barrier ();
10821082

1083+
mono_domain_unset();
10831084
SET_CURRENT_OBJECT (NULL);
1084-
mono_domain_unset ();
10851085

10861086
if (!mono_thread_info_try_get_internal_thread_gchandle (info, &gchandle))
10871087
g_error ("%s: failed to get gchandle, info = %p", __func__, info);

0 commit comments

Comments
 (0)