Skip to content

SILOptimzer: correct a case of UB #62508

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 12, 2022
Merged

Conversation

compnerd
Copy link
Member

@compnerd compnerd commented Dec 11, 2022

The current UpdatingInstructionIteratorRegistry referenced this in
the member initializer list. As per class.cdtor 11.9.5p1, this is UB as
for any class with a non-trivial constructor, referencing the base class
of the object before the constructor begins execution is not permitted.
We attempted to capture this in the lambda that was used to initialise
the member. This was being exploited by the MSVC compiler resulting in
incorrect execution of the instruction deleter.

@compnerd
Copy link
Member Author

CC: @jckarter @gottesmm

@compnerd
Copy link
Member Author

@swift-ci please test

@compnerd compnerd changed the title SILOptimzer: add a workaround to repair the Windows builds SILOptimzer: correct a case of UB Dec 12, 2022
@compnerd
Copy link
Member Author

@swift-ci please test

The current `UpdatingInstructionIteratorRegistry` referenced `this` in
the member initializer list.  As per class.cdtor 11.9.5p1, this is UB as
for any class with a non-trivial constructor, referencing the base class
of the object before the constructor begins execution is not permitted.
We attempted to capture `this` in the lambda that was used to initialise
the member.  This was being exploited by the MSVC compiler resulting in
incorrect execution of the instruction deleter.
@compnerd
Copy link
Member Author

@swift-ci please test

@compnerd compnerd merged commit d6efe55 into swiftlang:main Dec 12, 2022
@compnerd compnerd deleted the workaround branch December 13, 2022 04:31
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.

1 participant