From eff4cb5af8934b186574f2d7ebb1e2fae1b72351 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Sat, 13 Apr 2013 22:07:37 +0200 Subject: Clear the domain on thread exit after the profile thread end hook, since it might need it to be set. --- mono/metadata/threads.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/mono/metadata/threads.c b/mono/metadata/threads.c index b965ff2e484..e0ba2fde306 100644 --- a/mono/metadata/threads.c +++ b/mono/metadata/threads.c @@ -399,6 +399,15 @@ static void thread_cleanup (MonoInternalThread *thread) mono_profiler_thread_end (thread->tid); + if (thread == mono_thread_internal_current ()) { + /* + * This will signal async signal handlers that the thread has exited. + * The profiler callback needs this to be set, so it cannot be done earlier. + */ + mono_domain_unset (); + mono_memory_barrier (); + } + if (thread == mono_thread_internal_current ()) mono_thread_pop_appdomain_ref (); @@ -615,12 +624,6 @@ static guint32 WINAPI start_wrapper_internal(void *data) * for the current thead */ mono_thread_cleanup_apartment_state (); - /* - * This will signal async signal handlers that the thread has exited. - */ - mono_domain_unset (); - mono_memory_barrier (); - thread_cleanup (internal); /* Remove the reference to the thread object in the TLS data, -- cgit v1.2.3