Skip to content

[5.1][Runtime] Fix swift_conformsToProtocol crashing on conformances to unavailable classes. #26649

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

Conversation

mikeash
Copy link
Contributor

@mikeash mikeash commented Aug 14, 2019

Cherry-pick #26638 to 5.1.

An extension on a class creates a conformance record that's always visible even when that class is not present at runtime. In that case, the type pointer in the conformance record is NULL. The runtime did not like this, and crashed. This fixes it to ignore such records instead.

For back deployment to Swift 5.0, the swiftCompatibility50 library is extended to find conformance records with NULL type pointers and rewrite those pointers to point to a dummy type that will be ignored by the runtime.

rdar://problem/54054895

…available classes.

An extension on a class creates a conformance record that's always visible even when that class is not present at runtime. In that case, the type pointer in the conformance record is NULL. The runtime did not like this, and crashed. This fixes it to ignore such records instead.

rdar://problem/54054895
Add code to the 5.0 compatibility library that scans for conformances pointing to a NULL type and rewrites them to point to a dummy type that the 5.0 protocol conformance checking code will safely ignore.
@mikeash mikeash requested a review from a team as a code owner August 14, 2019 17:29
@mikeash
Copy link
Contributor Author

mikeash commented Aug 14, 2019

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - c1f4d99

@mikeash
Copy link
Contributor Author

mikeash commented Aug 14, 2019

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - c1f4d99

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - c1f4d99

@tkremenek
Copy link
Member

@swift-ci test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 7ca665b

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 7ca665b

@mikeash mikeash force-pushed the fix-protocol-conformances-on-unavailable-classes-5.1 branch from 8815ac0 to 7ca665b Compare August 15, 2019 01:27
@mikeash
Copy link
Contributor Author

mikeash commented Aug 15, 2019

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 8815ac07649b24473bd6021e259998cbee457faa

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 8815ac07649b24473bd6021e259998cbee457faa

@tkremenek tkremenek merged commit 1329017 into swiftlang:swift-5.1-branch Aug 15, 2019
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.

4 participants