-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Make _swift_willThrow atomic #62349
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
Make _swift_willThrow atomic #62349
Conversation
@swift-ci please test |
… be back-deployed correctly.
@swift-ci please test |
@swift-ci please test |
…e of Unmanaged is failing
@swift-ci please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Makes me wonder whether we do this for other callbacks, or whether we're relying on callers using them before going multithreaded or inserting their own barriers as appropriate.
We have hooks for retain/release and for the default global executor. THey're all implicitly relying on being set before multithreaded access happens. Retain/release is in practice set early in a static initializer inserted with |
The difference with this callback is, I think, that it's known that we set it late in execution, in another module, after other threads or tasks have already been spun up. That's why I opted to change it. I don't personally want to go around messing with those other callbacks unless somebody can show an example of them being set later in execution. |
FWIW the overhead of making the global executor hook atomic is going to be negligible, so if it can be set late or arbitrarily, I'd agree we should take steps to make it safer. I wouldn't dare say the overhead is negligible for retain/release, though. |
This change makes
_swift_willThrow
a C++ atomic value instead of a bare pointer. This change is necessary because the pointer can be loaded across multiple threads concurrently.Resolves #62348.