From 9aaa0083d0def5b940372dbd9375336b036249fd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Tue, 20 Jun 2017 02:34:17 +0200 Subject: [PATCH] [utils/threads] Print an error and abort if pthread_kill returns an error that isn't ESRCH. --- mono/utils/mono-threads-posix.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/mono/utils/mono-threads-posix.c b/mono/utils/mono-threads-posix.c index 5d0e1ab2911..d97d0adcc8c 100644 --- a/mono/utils/mono-threads-posix.c +++ b/mono/utils/mono-threads-posix.c @@ -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 -- 2.25.1