<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/102656>102656</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Fast path memory ordering is inconsistent between libcpp and libc
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
gbaraldi
</td>
</tr>
</table>
<pre>
libc uses a relaxed load https://github.com/llvm/llvm-project/blob/95820ca263cf1f6369928782882c2fd13633a7e9/libc/src/__support/threads/linux/callonce.h#L26-L28 while libcpp uses acquire https://github.com/llvm/llvm-project/blob/95820ca263cf1f6369928782882c2fd13633a7e9/libcxx/include/__mutex/once_flag.h#L127
A relaxed load has no ordering constraints so if one thread calls pthread_once and another goes through the fast path, even if the other thread observes the `FINISH` value. What guarantees that the side effects are visible from it?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8Uk1vnDAQ_TXmMsrKDIuBA4e0EWqkqJceelwNZgBXXpvaZpP8-8q7WUXqrZdezNebx5v3HsVoFsfci_qLqJ8K2tPqQ7-MFMhOphj99N5bM2rYI0cgCGzpjSewniZYU9qiqB4FDgKHxaR1Hw_anwUO1l7ul4ct-F-sk8BhtH4UOHR1i1ITqkrP5awq1XXYNi22LWqcp7JSVUUNd5nAjFrgEEM-T6e4b5sPmSqtgWmKV4jb3wQOmqz1TvNhFVi9oHp4wRZeV2MZMsu2feygf-8m8P8S_5alGaftPvF1hfOeOL_LUk-zpeWmt8RGyCchH2_n419OUwTnwYeJg3ELaO9iCmRcihA9mBm8Y7h5AtmICNvt6ZT_A-QmIOfTygEWzzFD_b6skFaGmWKCjdIq8CvwhV3myx9u-A9WP0YOl-sog1ByeP7-_OObUBIuZHc-wM-VEiw7BXKJrzhKV3A0EwPPM-sUgQLDxUQzWoY5-DOYJKqhmPpq6qqOCu7LBivEpq6aYu25HbGrlZoqrNuJKiRSrWxVyRobYlWYHiUeZSu7si3buj5IJWd9HKVS3VG2zSiOks9k7CHHefBhKUyMO_elRFWrwtLINt77H_pr6OO-RHGU1sQUP-eSSZb74e4WnPnsw_tnKCaCcTkZExO7BCOnV2Z3b1_OIN8We7D9P7fvKjrX_UP3pcc_AQAA__9hFjoh">