Runtime: Make swift_getObjCClassMetadata resilient against weakly linked classes #5055
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description: Whenever we would link against a swift overlay (like CallKit) that has weakly linked Objective-C classes we run the risk of crashing in runtime functions that access type metadata.
The type metadata is initiatialized with swift_getObjCClassMetadata. If the class is weakly linked and not present this function is called with a null (the weakly linked) class.
For example, we crash on iOS9 on a simple “print(“foo”)” call when this application links against CallKit.
Scope: At least three bug reports so far.
Risk: Very low, the fix is to return null if the class passed is null.
Tested: Verified that the reported crashers work after this change
Radar: rdar://problem/28203571 (also rdar://problem/28340074)
Reviewed by: Joe Groff
rdar://28203571