Skip to content

[5.3] Reflection Library crash inspecting certain BoundGeneric types (#32983) #33008

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

tbkka
Copy link
Contributor

@tbkka tbkka commented Jul 20, 2020

Propose merging #32983 to release/5.3

Original Description

If the parent of a BoundGeneric type is not a NominalType (for example, if the
Parent was an ObjCClass type) the getDepth() method would end up reading a
Parent reference from uninitialized memory. The resulting garbage pointer
would cause a crash in the tool that was using the reflection library
(leaks, instruments, etc.)

Of course, this does not always result in a crash, since the memory in question
is frequently zeroed, resulting in a nil pointer that is safely detected.

Resolves rdar://54173375

CCC Info

Risk: Low. Adds a missing type check to avoid a crash.

…lang#32983)

* Reflectio Library crash inspecting certain BoundGeneric types

If the parent of a BoundGeneric type is not a NominalType (for example, if the
Parent was an ObjCClass type) the `getDepth()` method would end up reading a
Parent reference from uninitialized memory.  The resulting garbage pointer
would cause a crash in the tool that was using the reflection library
(leaks, instruments, etc.)

Of course, this does not always result in a crash, since the memory in question
is frequently zeroed, resulting in a nil pointer that is safely detected.

Resolves rdar://54173375

* Fix compile
@tbkka tbkka requested a review from a team as a code owner July 20, 2020 20:37
@tbkka
Copy link
Contributor Author

tbkka commented Jul 20, 2020

@swift-ci Please test

@tbkka
Copy link
Contributor Author

tbkka commented Jul 20, 2020

@swift-ci Please nominate

@tbkka tbkka requested review from slavapestov and mikeash July 20, 2020 20:37
@tbkka tbkka merged commit 0b70435 into swiftlang:release/5.3 Jul 21, 2020
@tbkka tbkka deleted the tbkka/reflection-library-crash-54173375-5.3 branch October 16, 2020 00:34
@AnthonyLatsis AnthonyLatsis added swift 5.3 🍒 release cherry pick Flag: Release branch cherry picks labels Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks swift 5.3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants