Skip to content

[6.0][Runtime] Fix printing keypaths with LocalDeclName subscript types. #74665

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 Jun 24, 2024

Cherry-pick #74635 to release/6.0.

We assumed a bit too much about the structure of a single-argument subscript demangle tree and assumed that the argument identifier node was always in the same place. If it wasn't, we'd try to get text from the wrong node and get a bogus StringRef. Verify the node kind before trying to extract text, and handle LocalDeclName nodes as well as Identifier nodes.

rdar://129886558

We assumed a bit too much about the structure of a single-argument subscript demangle tree and assumed that the argument identifier node was always in the same place. If it wasn't, we'd try to get text from the wrong node and get a bogus StringRef. Verify the node kind before trying to extract text, and handle LocalDeclName nodes as well as Identifier nodes.

rdar://129886558
(cherry picked from commit 1a08891)
@mikeash mikeash requested a review from a team as a code owner June 24, 2024 20:23
@mikeash
Copy link
Contributor Author

mikeash commented Jun 24, 2024

@swift-ci please test

@mikeash
Copy link
Contributor Author

mikeash commented Jun 24, 2024

Explanation: Printing keypaths with certain contents could crash due to assuming a certain node would contain text without checking its type first.
Original PR: #74635
Reviewed by: @al45tair
Risk: Low. This preserves the original behavior when it's correct, handles one new case that previously crashed, and fails gracefully if the assumed node types aren't present.
Resolves: rdar://129886558
Tests: Added a new test to the suite to cover the case that crashed. Existing tests cover the existing non-crashing behavior.

@mikeash
Copy link
Contributor Author

mikeash commented Jul 8, 2024

@swift-ci please test

@mikeash mikeash enabled auto-merge July 8, 2024 17:34
@mikeash mikeash merged commit c8aee3c into swiftlang:release/6.0 Jul 9, 2024
5 checks passed
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