[compiler-rt] [TSAN] Add __tsan_check_no_mutexes_held helper (PR #69372)

Dmitry Vyukov via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 23 22:42:00 PDT 2023


================
@@ -216,11 +218,16 @@ static void PrintMutexShortWithAddress(const ReportMutex *rm,
          reinterpret_cast<void *>(rm->addr), d.Default(), after);
 }
 
-static void PrintMutex(const ReportMutex *rm) {
+static void PrintMutex(const ReportMutex *rm, ReportType typ) {
   Decorator d;
   Printf("%s", d.Mutex());
-  Printf("  Mutex M%u (%p) created at:\n", rm->id,
-         reinterpret_cast<void *>(rm->addr));
+  if (typ != ReportTypeMutexCannotBeLocked) {
+    Printf("  Mutex M%u (%p) created at:\n", rm->id,
+           reinterpret_cast<void *>(rm->addr));
+  } else {
+    Printf("  Mutex M%u (%p) acquired at:\n", rm->id,
+           reinterpret_cast<void *>(rm->addr));
+  }
----------------
dvyukov wrote:

I think it still will be creation stack (in the test you got lock stack because you forgot to init the mutex). Or it may be a lock stack in a different thread/context.
It's basically the stack that somehow identifies the mutex for the user.
So I don't think this part of the change is necessary.

https://github.com/llvm/llvm-project/pull/69372


More information about the llvm-commits mailing list