From df2f9b01d29dcc6d24d3ca52894566ac439eb9db Mon Sep 17 00:00:00 2001 From: Rickard Date: Mon, 8 Jun 2020 18:57:04 +0200 Subject: [PATCH] Avoid setting PTHREAD_PRIO_INHERIT on Alpine, since this causes deadlocks (#19914) Fixes #7167 The PR 3e8108ea6576b07de2a64528be18674683879189 introduced a deadlock on Alpine, making it impossible to even build mono. This PR reverts the setting of PTHREAD_PRIO_INHERIT when on Alpine. Since GCC on Alpine doesn't provide a builtin macro to detect Alpine, I also added a #define in configure.ac. --- configure.ac | 5 +++++ mono/utils/mono-os-mutex.h | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 6eb961f9dda0..ad29946527f1 100644 --- a/configure.ac +++ b/configure.ac @@ -320,6 +320,11 @@ case "$host" in # available during cross-compilation mono_cv_uscore=no fi + case "$host" in + *-musl) + AC_DEFINE(MUSL, 1, [musl libc]) + ;; + esac case "$host" in *-tizen-linux-*) platform_tizen=yes diff --git a/mono/utils/mono-os-mutex.h b/mono/utils/mono-os-mutex.h index 8b2f530f108e..904974b0a083 100644 --- a/mono/utils/mono-os-mutex.h +++ b/mono/utils/mono-os-mutex.h @@ -59,7 +59,7 @@ mono_os_mutex_init_type (mono_mutex_t *mutex, int type) if (G_UNLIKELY (res != 0)) g_error ("%s: pthread_mutexattr_settype failed with \"%s\" (%d)", __func__, g_strerror (res), res); -#if !defined(__HAIKU__) && defined (PTHREAD_PRIO_INHERIT) && HAVE_DECL_PTHREAD_MUTEXATTR_SETPROTOCOL +#if !defined(__HAIKU__) && !defined(MUSL) && defined (PTHREAD_PRIO_INHERIT) && HAVE_DECL_PTHREAD_MUTEXATTR_SETPROTOCOL /* use PTHREAD_PRIO_INHERIT if possible */ res = pthread_mutexattr_setprotocol (&attr, PTHREAD_PRIO_INHERIT); if (G_UNLIKELY (res != 0 && res != ENOTSUP))