-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Runtime] Fix crash in protocol conformance checks on KVO artificial subclasses. #37973
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
…subclasses. tryGetCompleteMetadataNonblocking crashes on artificial subclasses due to the NULL type descriptor. Explicitly check for artificial subclasses in getSuperclassForMaybeIncompleteMetadata and immediately return their Superclass field. Artificial subclasses are always fully initialized so we don't need to do anything special for them. rdar://72583931
// tryGetCompleteMetadataNonblocking will crash on them. However, they're | ||
// always fully set up, so we can just skip it and fetch the Subclass field. | ||
if (classMetadata->isTypeMetadata() && classMetadata->isArtificialSubclass()) | ||
return {classMetadata->Superclass, MetadataState::Complete}; |
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.
In other places, we do this check for artificial subclasses in a loop, crawling up the superclass tree until we find a real class. I don't know if that's just paranoia, though.
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.
That can happen at least in theory. No idea if it happens in reality, but it's good to handle. In this particular case, the loop is exterior to this function, as other code uses this function to walk the entire superclass chain. Returning artificial subclasses in that loop is unnecessary but harmless.
@swift-ci please test |
Build failed |
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.
Looks good then. Thanks Mike!
Build failed |
@swift-ci please test macOS platform |
Build failed |
@swift-ci please test macos platform |
Build failed |
@swift-ci please smoke test macOS platform |
tryGetCompleteMetadataNonblocking crashes on artificial subclasses due to the NULL type descriptor. Explicitly check for artificial subclasses in getSuperclassForMaybeIncompleteMetadata and immediately return their Superclass field. Artificial subclasses are always fully initialized so we don't need to do anything special for them.
rdar://72583931