Skip to content

Commit e02fab6

Browse files
committed
Check the return code from pthread_mutex_unlock to verify we actually held the mutex
1 parent ddd4315 commit e02fab6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/common/debug.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,10 @@ typedef struct {
147147
# define tracing_mutex_unlock(x) do { \
148148
(x)->mtx_status = MTX_UNLOCKED; \
149149
(x)->mtx_owner = -1; \
150-
pthread_mutex_unlock(&((x)->mtx_lock)); \
150+
if (unlikely(pthread_mutex_unlock(&((x)->mtx_lock)) < 0)) {\
151+
dbg_perror("pthread_mutex_unlock"); \
152+
assert(0); \
153+
}; \
151154
dbg_printf("[%i]: unlocked %s", __LINE__, # x); \
152155
} while (0)
153156

0 commit comments

Comments
 (0)