[utils/threads] Print an error and abort if pthread_kill returns an error that isn...
authorAlex Rønne Petersen <alexrp@xamarin.com>
Tue, 20 Jun 2017 00:34:17 +0000 (02:34 +0200)
committerAlex Rønne Petersen <alexrp@xamarin.com>
Tue, 20 Jun 2017 03:39:11 +0000 (05:39 +0200)
mono/utils/mono-threads-posix.c

index 5d0e1ab29112e3e8b0ce624e2cbd257a6519f077..d97d0adcc8c8e0f1435a20d9ef94a6309f606684 100644 (file)
@@ -142,19 +142,28 @@ int
 mono_threads_pthread_kill (MonoThreadInfo *info, int signum)
 {
        THREADS_SUSPEND_DEBUG ("sending signal %d to %p[%p]\n", signum, info, mono_thread_info_get_tid (info));
+
+       int result;
+
 #ifdef USE_TKILL_ON_ANDROID
-       int result, old_errno = errno;
+       int old_errno = errno;
+
        result = tkill (info->native_handle, signum);
+
        if (result < 0) {
                result = errno;
                errno = old_errno;
        }
-       return result;
-#elif !defined(HAVE_PTHREAD_KILL)
-       g_error ("pthread_kill() is not supported by this platform");
+#elif defined (HAVE_PTHREAD_KILL)
+       result = pthread_kill (mono_thread_info_get_tid (info), signum);
 #else
-       return pthread_kill (mono_thread_info_get_tid (info), signum);
+       g_error ("pthread_kill () is not supported by this platform");
 #endif
+
+       if (result && result != ESRCH)
+               g_error ("%s: pthread_kill failed with error %d - potential kernel OOM or signal queue overflow", __func__, result);
+
+       return result;
 }
 
 MonoNativeThreadId