<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/59808>59808</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
__release_capability__ method and __scoped_capability__ causes double-release to be missed.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
brunowonka
</td>
</tr>
</table>
<pre>
The following code snipper causes `-Wthread-safety` to miss a double lock release when a method that releases a lock is used in conjunction with a scoped lock.
``` c++
class Foo {
void foo() {
// Fails to generate a warning.
AutoLock lock(&lock_);
teardown();
}
void baz() {
// Correctly generates a warning.
lock_.Acquire();
teardown();
lock_.Release();
}
void teardown() __attribute__((__release_capability__(lock_))) {
lock_.Release();
}
private:
MyLock lock_;
};
```
godbolt: https://godbolt.org/z/YrcbdG1b1
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyElE2PmzwQxz-NuYwSgYEEDhyyT8RzaS9Vpaon5JdJ8K7jSW2zUfbTVxA2TXa3XcsC5Bn_5zcexiIEs3eIDSsfWLlNxBB78o30g6MTuSeRSNLn5nuPsCNr6WTcHhRphODM8YgelBgCBmCrdPEj9h6FXgSxw3hmqxQiwcGEAAI0DdIiWFJP4NGiCAinHh0IOGDsSUPsRXw1jTsmVxNgCKjBOFDkHgenoiEHJxN7EBAUHVFPnkuWblm6mZ-r9DJBMf4wzmlZWRECtETA1vMSAMAzGQ07IsYrxut72zgYbxlvoRXGhjGjPTr0IiIIOAnvjNvPwWEzRPoyYo9Ek9xq_OoYr1n-RjWi8JpO7hL1zszW29tsroxSvHzC-B95jyra8xUyvKeckJYb9WswHj8I_wndOC4S3y7FeuvzN_x7Teg6EaM3cojYddNa1XVz_TsljkIaa-J5sl1PcZrv0_8nz-2JHr15FhFZfgP39XytWcfyB5jh19urxPV_us1rT1qSjSzfQB_jMYyaUxVmw5L8nvH2hfH2p1dS_5_JLNFNruu8Fgk22WrN1xUvqjrpm0rkaaVW2W63U0rwIteqKLOcV_mal3WpEtPwlOdpluY8K6q0XqIqVjIreKl5JbOqZEWKB2Hs0trnwxg7MSEM2JR1lVaJFRJtmLqcc4cnmIyM87HpfTPuWchhH1iRWhNi-KMSTbTYfFyZ19YVTkPXXbrx3mG-HS7dv3ht_EggcboZUC-TwdvmzQma2A9yqejAeDuSzK_F0dMjqsh4O_EHxtspv98BAAD__5lybc8">