Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the failure memory order argument to compareExchangeStrong #22049

Merged
merged 1 commit into from
Dec 22, 2023

Conversation

AtariDreams
Copy link
Contributor

@AtariDreams AtariDreams commented Dec 19, 2023

d2ba4a0

Fix the failure memory order argument to compareExchangeStrong
https://bugs.webkit.org/show_bug.cgi?id=266649

Reviewed by Kimmo Kinnunen.

The failure memory order cannot be release or acq_rel.
Clang since llvm/llvm-project@fed5644 diagnoses an invalid argument.
Furthermore, the current way it is written is undefined behavior anyway.

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."

* Source/WebKit/Platform/IPC/StreamClientConnectionBuffer.h:
  (IPC::StreamClientConnectionBuffer::tryAcquire): Use
  memory_order_acquire as fallback.
* Source/WebKit/Platform/IPC/StreamServerConnectionBuffer.h:
  (IPC::StreamServerConnectionBuffer::tryAcquire): Ditto.

Canonical link: https://commits.webkit.org/272461@main

83b9eb4

Misc iOS, tvOS & watchOS macOS Linux Windows
  πŸ§ͺ style   πŸ›  ios   πŸ›  mac   πŸ›  wpe   πŸ›  wincairo
  πŸ›  ios-sim   πŸ›  mac-AS-debug   πŸ§ͺ wpe-wk2
  πŸ§ͺ webkitperl   πŸ§ͺ ios-wk2   πŸ§ͺ api-mac   πŸ§ͺ api-wpe
  πŸ§ͺ ios-wk2-wpt   πŸ§ͺ mac-wk1   πŸ›  gtk
  πŸ§ͺ api-ios   πŸ§ͺ mac-wk2   πŸ§ͺ gtk-wk2
  πŸ›  tv   πŸ§ͺ mac-AS-debug-wk2   πŸ§ͺ api-gtk
  πŸ›  tv-sim   πŸ§ͺ mac-wk2-stress
βœ… πŸ›  πŸ§ͺ merge   πŸ›  watch
  πŸ›  watch-sim

@Ahmad-S792 Ahmad-S792 added the Platform Portability improvements and other general platform improvements not driven directly by site bugs. label Dec 19, 2023
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Dec 20, 2023
@AtariDreams
Copy link
Contributor Author

@kkinnunen-apple Could you please review this?

@AtariDreams
Copy link
Contributor Author

@aproskuryakov Do you think this is safe to merge? Considering the failure only means we have to acquire anyway, no behavior should really change. I would be surprised if it generated different binary honestly.

@aproskuryakov
Copy link
Contributor

I am not familiar with this code, neither WebKit side nor C++ library side.

Copy link
Member

@aprotyas aprotyas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will need a review from someone who's familiar with WTF::Atomic.

I think the change is good, but you should have explained better in your changelog that the status quo is undefined behavior. Can you update your commit message to reflect that?

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.

@AtariDreams
Copy link
Contributor Author

This will need a review from someone who's familiar with WTF::Atomic.

I think the change is good, but you should have explained better in your changelog that the status quo is undefined behavior. Can you update your commit message to reflect that?

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.

Done!

@aprotyas aprotyas added the skip-ews Applied to prevent a change from being run on EWS label Dec 22, 2023
@AtariDreams
Copy link
Contributor Author

@aproskuryakov Can we please merge this?

@MenloDorian
Copy link

MenloDorian commented Dec 22, 2023

This will need a review from someone who's familiar with WTF::Atomic.
I think the change is good, but you should have explained better in your changelog that the status quo is undefined behavior. Can you update your commit message to reflect that?
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.

Done!

Please add the url above in the commit message as well. The url provides details to explain that this is the correct fix. Thanks.

@AtariDreams
Copy link
Contributor Author

@AtariDreams
Copy link
Contributor Author

From https://en.cppreference.com/w/cpp/atomic/atomic/compare_exchange

Done!

@MenloDorian Can we please merge this now?

@aprotyas
Copy link
Member

I'll merge this later today.

@AtariDreams
Copy link
Contributor Author

I'll merge this later today.

Alright. I added the requested changes to the actual pull request message.

@aprotyas aprotyas added safe-merge-queue Applied to automatically send a pull-request to merge-queue after passing EWS checks merge-queue Applied to send a pull request to merge-queue and removed merging-blocked Applied to prevent a change from being merged skip-ews Applied to prevent a change from being run on EWS safe-merge-queue Applied to automatically send a pull-request to merge-queue after passing EWS checks labels Dec 22, 2023
https://bugs.webkit.org/show_bug.cgi?id=266649

Reviewed by Kimmo Kinnunen.

The failure memory order cannot be release or acq_rel.
Clang since llvm/llvm-project@fed5644 diagnoses an invalid argument.
Furthermore, the current way it is written is undefined behavior anyway.

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."

* Source/WebKit/Platform/IPC/StreamClientConnectionBuffer.h:
  (IPC::StreamClientConnectionBuffer::tryAcquire): Use
  memory_order_acquire as fallback.
* Source/WebKit/Platform/IPC/StreamServerConnectionBuffer.h:
  (IPC::StreamServerConnectionBuffer::tryAcquire): Ditto.

Canonical link: https://commits.webkit.org/272461@main
@webkit-commit-queue
Copy link
Collaborator

Committed 272461@main (d2ba4a0): https://commits.webkit.org/272461@main

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform Portability improvements and other general platform improvements not driven directly by site bugs.
Projects
None yet
9 participants