<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - False Positive PthreadLockChecker Use destroyed lock"
   href="https://bugs.llvm.org/show_bug.cgi?id=32455">32455</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>False Positive PthreadLockChecker Use destroyed lock
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Static Analyzer
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>kremenek@apple.com
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>xiangzhai83@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Hi LLVM developers,

Testcase: libburn
<a href="https://dev.lovelyhq.com/libburnia/libburn/blob/master/libburn/libdax_msgs.c#L209">https://dev.lovelyhq.com/libburnia/libburn/blob/master/libburn/libdax_msgs.c#L209</a>

208     #ifndef LIBDAX_MSGS_SINGLE_THREADED
209      if(pthread_mutex_destroy(&(o->lock_mutex))!=0) {
          ^
          Assuming the condition is true        

          ^
          Taking true branch    

210        pthread_mutex_unlock(&(o->lock_mutex));
           ^
           This lock has already been destroyed

211        pthread_mutex_destroy(&(o->lock_mutex));
212      }
213     #endif


But if the return value of pthread_mutex_destroy is NOT 0
<a href="https://github.molgen.mpg.de/git-mirror/glibc/blob/master/nptl/pthread_mutex_destroy.c#L32">https://github.molgen.mpg.de/git-mirror/glibc/blob/master/nptl/pthread_mutex_destroy.c#L32</a>
then mutex->__data.__kind will not be set! so it might be still able to use
pthread_mutex_unlock to set mutex object's members
<a href="https://github.molgen.mpg.de/git-mirror/glibc/blob/master/nptl/pthread_mutex_unlock.c#L49">https://github.molgen.mpg.de/git-mirror/glibc/blob/master/nptl/pthread_mutex_unlock.c#L49</a>


Regards,
Leslie Zhai</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>