First set of licensing changes
[mono.git] / mono / mini / mini-posix.c
index 1acee9adb16664099e5a8e2519022186b1365206..7be84488f5877f979e259857c2383e12c373d542 100644 (file)
@@ -9,6 +9,7 @@
  * Copyright 2011 Xamarin, Inc (http://www.xamarin.com)
  *
  * See LICENSE for licensing information.
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
  */
 #include <config.h>
 #include <signal.h>
@@ -326,7 +327,6 @@ per_thread_profiler_hit (void *ctx)
 
 MONO_SIG_HANDLER_FUNC (static, sigprof_signal_handler)
 {
-       MonoThreadInfo *info;
        int old_errno = errno;
        int hp_save_index;
        MONO_SIG_HANDLER_GET_CONTEXT;
@@ -342,12 +342,13 @@ MONO_SIG_HANDLER_FUNC (static, sigprof_signal_handler)
        /* If we can't consume a profiling request it means we're the initiator. */
        if (!(mono_threads_consume_async_jobs () & MONO_SERVICE_REQUEST_SAMPLE)) {
                FOREACH_THREAD_SAFE (info) {
-                       if (mono_thread_info_get_tid (info) == mono_native_thread_id_get ())
+                       if (mono_thread_info_get_tid (info) == mono_native_thread_id_get () ||
+                           !mono_thread_info_is_live (info))
                                continue;
 
                        mono_threads_add_async_job (info, MONO_SERVICE_REQUEST_SAMPLE);
                        mono_threads_pthread_kill (info, profiling_signal_in_use);
-               } END_FOREACH_THREAD_SAFE;
+               } FOREACH_THREAD_SAFE_END
        }
 
        mono_thread_info_set_is_async_context (TRUE);