[llvm-bugs] [Bug 51913] New: Thread safety analysis: False negatives for exclusive/shared joins on back edges

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Sep 20 09:00:04 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=51913

            Bug ID: 51913
           Summary: Thread safety analysis: False negatives for
                    exclusive/shared joins on back edges
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: aaronpuchert at alice-dsl.net
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

Since https://reviews.llvm.org/D102026 we don't warn on this code:

// https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutex-h
#include "mutex.h"

Mutex mu;
int x GUARDED_BY(mu);

void f() {
  MutexLocker scope(&mu);
  for (unsigned i = 1; i < 10; ++i) {
    x = 1;
    if (i == 5) {
      scope.Unlock();
      scope.ReaderLock();
    }
  }
}

On the first iteration we have mu exclusively and can modify x, but on later
iterations we might not. So we can't allow this join to be silent.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210920/a22b74c9/attachment.html>


More information about the llvm-bugs mailing list