Skip to content

[5.5] Concurrency: fix UB in DefaultActor initialization #40263

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

Merged
merged 1 commit into from
Dec 3, 2021

Conversation

compnerd
Copy link
Member

This fixes a latent UB instance in the DefaultActor implementation
that has haunted the Windows target. The shared constructor for the
type caused an errant typo that happened to compile which introduced
UB but happened to work for the non-Windows cases. This happened to
work for the other targets as swift::atomic had a std::atomic at
on most configurations, and the C delegate for the Actor initializer
happened to overlap and initialize the memory properly. The Windows
case used an inline pointer width value but would be attempted to be
initialized as a std::atomic. Relying on the overlap is unsafe to
assume, and we should use the type's own constructor which delegates
appropriately.

Replace this paragraph with a description of your changes and rationale. Provide links to external references/discussions if appropriate.

Resolves SR-NNNN.

This fixes a latent UB instance in the `DefaultActor` implementation
that has haunted the Windows target.  The shared constructor for the
type caused an errant typo that happened to compile which introduced
UB but happened to work for the non-Windows cases.  This happened to
work for the other targets as `swift::atomic` had a `std::atomic` at
on most configurations, and the C delegate for the Actor initializer
happened to overlap and initialize the memory properly.  The Windows
case used an inline pointer width value but would be attempted to be
initialized as a `std::atomic`.  Relying on the overlap is unsafe to
assume, and we should use the type's own constructor which delegates
appropriately.
@compnerd compnerd requested a review from a team as a code owner November 19, 2021 15:53
@compnerd
Copy link
Member Author

@swift-ci please test

@compnerd
Copy link
Member Author

CC: @mikeash @rjmccall

@compnerd compnerd changed the title Concurrency: fix UB in DefaultActor initialization [5.5] Concurrency: fix UB in DefaultActor initialization Nov 19, 2021
@compnerd
Copy link
Member Author

Cherry-picked from #40260

@tkremenek tkremenek merged commit 9026b6e into swiftlang:release/5.5 Dec 3, 2021
@compnerd compnerd deleted the 5.5-ub-async branch December 3, 2021 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants