Bug 266649 - Failure memory order cannot be release or acq_rel.
Summary: Failure memory order cannot be release or acq_rel.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Platform (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2023-12-19 11:15 PST by Seija K.
Modified: 2023-12-22 13:05 PST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Seija K. 2023-12-19 11:15:14 PST
It is undefined behavior and clang now enforces this.
Comment 1 Alexey Proskuryakov 2023-12-20 09:59:46 PST
https://github.com/WebKit/WebKit/pull/22049
Comment 2 Mark Lam 2023-12-20 10:14:46 PST
(In reply to Seija K. from comment #0)
> It is undefined behavior and clang now enforces this.

Can you please point us to the C++ spec where it says that using release or acq_rel for the failure memory order is undefined behavior?  Thanks.
Comment 3 Radar WebKit Bug Importer 2023-12-22 08:29:21 PST
<rdar://problem/120047049>
Comment 4 Mark Lam 2023-12-22 08:32:03 PST
(In reply to Mark Lam from comment #2)
> Can you please point us to the C++ spec where it says that using release or
> acq_rel for the failure memory order is undefined behavior?  Thanks.

From https://en.cppreference.com/w/cpp/atomic/atomic/compare_exchange:
```
If failure is stronger than success or(until C++17) is one of std::memory_order_release and std::memory_order_acq_rel, the behavior is undefined.
```

Also, from that link, there's a table that says for `compare_exchange_strong`'s "load operation" in the failure mode, to use:
```
* std::memory_order_acquire if order is std::memory_order_acq_rel
* std::memory_order_relaxed if order is std::memory_order_release
* otherwise order
```
Comment 5 EWS 2023-12-22 13:05:12 PST
Committed 272461@main (d2ba4a07e209): <https://commits.webkit.org/272461@main>

Reviewed commits have been landed. Closing PR #22049 and removing active labels.