summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2021-07-21 15:22:04 -0700
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-07-27 04:49:00 -0400
commitb19f1a6a541645b735e01aa2658f5493fb1cc97d (patch)
tree2a70600bf6ad4a74636a392c67a9dc4c2c91eeb0
parent5457a1249fe0ccaf31d1d96478ce606041b41e9f (diff)
downloadhaskell-b19f1a6a541645b735e01aa2658f5493fb1cc97d.tar.gz
rts/OSThreads: Ensure that we catch failures from pthread_mutex_lock
Previously we would only catch EDEADLK errors.
-rw-r--r--includes/rts/OSThreads.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/includes/rts/OSThreads.h b/includes/rts/OSThreads.h
index b57799fd55..b711036b17 100644
--- a/includes/rts/OSThreads.h
+++ b/includes/rts/OSThreads.h
@@ -44,11 +44,12 @@ typedef pthread_key_t ThreadLocalKey;
#endif
/* Always check the result of lock and unlock. */
-#define OS_ACQUIRE_LOCK(mutex) \
+#define OS_ACQUIRE_LOCK(mutex) { \
LOCK_DEBUG_BELCH("ACQUIRE_LOCK", mutex); \
- if (pthread_mutex_lock(mutex) == EDEADLK) { \
- barf("multiple ACQUIRE_LOCK: %s %d", __FILE__,__LINE__); \
- }
+ int __r = pthread_mutex_lock(mutex); \
+ if (__r != 0) { \
+ barf("ACQUIRE_LOCK failed (%s:%d): %d", __FILE__, __LINE__, __r); \
+ } }
// Returns zero if the lock was acquired.
EXTERN_INLINE int OS_TRY_ACQUIRE_LOCK(pthread_mutex_t *mutex);