diff --git a/lib/libspl/assert.c b/lib/libspl/assert.c index 185ec65cb8..d402462531 100644 --- a/lib/libspl/assert.c +++ b/lib/libspl/assert.c @@ -27,6 +27,7 @@ */ #include +#include #if defined(__linux__) #include @@ -56,11 +57,15 @@ libspl_set_assert_ok(boolean_t val) libspl_assert_ok = val; } +static pthread_mutex_t assert_lock = PTHREAD_MUTEX_INITIALIZER; + /* printf version of libspl_assert */ void libspl_assertf(const char *file, const char *func, int line, const char *format, ...) { + pthread_mutex_lock(&assert_lock); + va_list args; char tname[64]; @@ -80,6 +85,7 @@ libspl_assertf(const char *file, const char *func, int line, #if !__has_feature(attribute_analyzer_noreturn) && !defined(__COVERITY__) if (libspl_assert_ok) { + pthread_mutex_unlock(&assert_lock); return; } #endif