<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/60943>60943</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang: crash on recursive RETURN_CAPABILITY attribute
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
klirichek
</td>
</tr>
</table>
<pre>
MRE:
```C++
#define RETURN_CAPABILITY( x ) __attribute__ (( lock_returned ( x ) ))
#define REQUIRES( ... ) __attribute__ (( requires_capability ( __VA_ARGS__ ) ))
using SchedRole [[clang::capability("role")]] = bool;
class foo {
SchedRole m_thread;
public:
// notice - erroneously return cap getRole() instead of m_thread here.
SchedRole getRole() const RETURN_CAPABILITY ( getRole() )
{
return m_thread;
}
};
void bar (foo& a) REQUIRES(a.getRole()) {}
```
Need to be compiled with `-Wthread-safety`
Most of the versions just silently returns with code 139, however I've found one which produces readable backtrace.
https://godbolt.org/z/766v79nh1
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx0VF2P4jYU_TXOyxWRcUhCHvIAw1CN1F21zG6rPkX-uCFeTExthyn99ZUDAwzTlaxg4XPPOT6-Nvdeb3vEmuRLkq8SPoTOunpntNOyw10irDrVXzbPJFsQuiJ0QQp6Hk-ELeM4_8syha3uETbP375vvjZPi98Wy5dfX779Rdgc_gHCKmgaHoLTYgjYNEDYPC4ZK3eNwzC4HhXcwIRVcXxi__37y-b5NeLSNP05rcO_B-3QN5IfuNBGh9NI3jR_LJrF5pfXEfogM34Hr_stvMoO1cYahDGZpTS838YQssWNcdRizhokjEWafEXyFZBsBcJaQ7LlPbE03HtorQVSXhYA4E5p34TOIVfXusMgjJbX6COasDVha-ht0BJhAuic7dEO3pzgnCJIfoAths1oax43qXsfkCuw7VUDOnSYvturbiY-Vkrb-_D5TMcoPyLvUqyu-4tzWl18fdreiFxd5uXqIa6j1QoEd1GrtZawAngUumsBnn7wMNoolzfO91a9p_2KqCBYEAjS7g_aoII3HTogBZ38eXY48bzFcHqo_GJ9iBGGDuGIzmvbe_gx-ABeG-zD9QT8mVBahTDNKsKeoLNveEQHL4SVR4TWDr0C2yO8dVp2cHBWDRI9RHUuDILgchccl7czit8uhIOP_TB2wdYqYU1IrdsStv6XsHVZFMey6rtpoupMVVnFE6ynRVlOZzmd5klXq1zNsqIqqSpKgRXPWzqlopItFaVUcpbomlGWUcYyWmVFnqdUZLLKWpXNseViLsmM4p5rkxpz3EftRHs_YF3QapYlhgs0_v05cXUETcSw9WRGjfbB38qCDgbrp8vFAum478D24FAOzuvj_7wlcL3pyeBM_RCHDt0gUmn3hK2jyuVncnD2B8pA2Hp06glbj2b_CwAA__8rhH36">