Skip to content

IRGen: Fix DynamicSelfType metadata recovery in @objc convenience inializers #24758

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

Conversation

slavapestov
Copy link
Contributor

An @objc convenience initializer can replace 'self'. Since IRGen has no way to tell what the new 'self' value is from looking at SIL, it always refers back to the original 'self' argument when recovering DynamicSelfType metadata. This could cause a crash if the metadata was used after the 'self' value had been replaced.

To fix the crash, always insert the metadata recovery into the entry block, where the 'self' value should be valid (even if uninitialized, the 'isa' pointer should be correct).

Fixes rdar://problem/50594689.

…tializers

An @objc convenience initializer can replace 'self'. Since IRGen
has no way to tell what the new 'self' value is from looking at
SIL, it always refers back to the original 'self' argument when
recovering DynamicSelfType metadata. This could cause a crash
if the metadata was used after the 'self' value had been
replaced.

To fix the crash, always insert the metadata recovery into the
entry block, where the 'self' value should be valid (even if
uninitialized, the 'isa' pointer should be correct).

Fixes <rdar://problem/50594689>.
@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@slavapestov slavapestov requested a review from jckarter May 14, 2019 03:16
@slavapestov slavapestov merged commit 2a87b68 into swiftlang:master May 14, 2019
Copy link
Contributor

@jckarter jckarter left a comment

Choose a reason for hiding this comment

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

LGTM

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.

2 participants