Skip to content

Reflection Library crash inspecting certain BoundGeneric types #32983

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
merged 2 commits into from
Jul 20, 2020

Conversation

tbkka
Copy link
Contributor

@tbkka tbkka commented Jul 18, 2020

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.

This changes getDepth() to detect unrecognized types and return zero.

Resolves rdar://54173375

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
@tbkka tbkka requested a review from slavapestov July 18, 2020 22:30
@tbkka
Copy link
Contributor Author

tbkka commented Jul 18, 2020

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 412f6b6

@tbkka
Copy link
Contributor Author

tbkka commented Jul 18, 2020

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 412f6b6

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 412f6b6

@tbkka
Copy link
Contributor Author

tbkka commented Jul 19, 2020

@swift-ci Please test Linux

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - f39bed2

@tbkka
Copy link
Contributor Author

tbkka commented Jul 19, 2020

@swift-ci Please smoke test Linux

@tbkka
Copy link
Contributor Author

tbkka commented Jul 19, 2020

@swift-ci Please smoke test

@tbkka
Copy link
Contributor Author

tbkka commented Jul 20, 2020

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - f39bed2

@tbkka tbkka merged commit 728abe9 into swiftlang:master Jul 20, 2020
tbkka added a commit to tbkka/swift that referenced this pull request Jul 20, 2020
…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 added a commit that referenced this pull request Jul 21, 2020
… (#33008)

* 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 deleted the tbkka/reflection-library-crash-54173375 branch October 16, 2020 00:34
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