[clang] [analyzer] Fix null-pointer dereference in PthreadLockChecker (PR #210912)

Arseniy Zaostrovnykh via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 21 05:55:32 PDT 2026


https://github.com/necto updated https://github.com/llvm/llvm-project/pull/210912

>From 9d7ad66b8e999fbc3b80014d47b122dad54a749f Mon Sep 17 00:00:00 2001
From: Arseniy Zaostrovnykh <necto.ne at gmail.com>
Date: Mon, 20 Jul 2026 13:20:00 +0200
Subject: [PATCH] Crashing test case

---
 clang/test/Analysis/pthreadlock.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/clang/test/Analysis/pthreadlock.c b/clang/test/Analysis/pthreadlock.c
index e931569c45ab8..6320a3d34600b 100644
--- a/clang/test/Analysis/pthreadlock.c
+++ b/clang/test/Analysis/pthreadlock.c
@@ -18,6 +18,25 @@ lck_rw_t rw;
 
 #define NULL 0
 
+long global_var;
+void noCrash(void) {
+  // Produce a complicated self-contradictory constraint
+  if ((global_var >> 48 & (1ULL << 8) - 1) == 2) {
+  }
+  if (global_var >> 48 & (1ULL << 8) - 1 & 8) {
+  }
+  pthread_mutex_lock(&mtx1); // no-warning
+}
+
+void noCrashTryLock(void) {
+  // Produce a complicated self-contradictory constraint
+  if ((global_var >> 48 & (1ULL << 8) - 1) == 2) {
+  }
+  if (global_var >> 48 & (1ULL << 8) - 1 & 8) {
+  }
+  pthread_mutex_trylock(&mtx1); // no-warning
+}
+
 void
 ok1(void)
 {



More information about the cfe-commits mailing list