Skip to content

Commit 63652bf

Browse files
alexrpluhenry
authored andcommitted
[utils/threads] Gracefully handle ENOTSUP from pthread_kill () on Apple platforms. (mono#6754)
1 parent 96082e3 commit 63652bf

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

mono/utils/mono-threads-posix.c

+18-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,24 @@ mono_threads_pthread_kill (MonoThreadInfo *info, int signum)
161161
g_error ("pthread_kill () is not supported by this platform");
162162
#endif
163163

164-
if (result && result != ESRCH)
164+
/*
165+
* ESRCH just means the thread is gone; this is usually not fatal.
166+
*
167+
* ENOTSUP can occur if we try to send signals (e.g. for sampling) to Grand
168+
* Central Dispatch threads on Apple platforms. This is kinda bad, but
169+
* since there's really nothing we can do about it, we just ignore it and
170+
* move on.
171+
*
172+
* All other error codes are ill-documented and usually stem from various
173+
* OS-specific idiosyncracies. We want to know about these, so fail loudly.
174+
* One example is EAGAIN on Linux, which indicates a signal queue overflow.
175+
*/
176+
if (result &&
177+
result != ESRCH
178+
#if defined (__MACH__) && defined (ENOTSUP)
179+
&& result != ENOTSUP
180+
#endif
181+
)
165182
g_error ("%s: pthread_kill failed with error %d - potential kernel OOM or signal queue overflow", __func__, result);
166183

167184
return result;

0 commit comments

Comments
 (0)