Skip to content

[Runtime] Fix subscript key path printing when arguments can't be resolved. #63305

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

mikeash
Copy link
Contributor

@mikeash mikeash commented Jan 30, 2023

If there's a mismatch between the arguments we match and the arguments we actually have, we can end up indexing off the end of the argumentTypeNames vector. This can happen when an argument has a dependent generic type. Add a bounds check and print when we're out of bounds to avoid crashing.

For correctness, we should match generic dependent types and add them to the arguments array, but we'll fix the crashes first.

rdar://104438524
Fixes #64865

@mikeash mikeash requested a review from al45tair January 30, 2023 19:12
@mikeash
Copy link
Contributor Author

mikeash commented Jan 30, 2023

@swift-ci please test

@mikeash mikeash force-pushed the print-keypath-dependent-generic-type branch from f858eed to 19d3a32 Compare January 31, 2023 18:43
@mikeash
Copy link
Contributor Author

mikeash commented Jan 31, 2023

@swift-ci please test

@mikeash
Copy link
Contributor Author

mikeash commented Feb 1, 2023

@swift-ci please test linux platform

if (i < argumentTypeNames.size())
return argumentTypeNames[i];
return std::string("<unknown>");
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:-) Neat fix.

@mikeash
Copy link
Contributor Author

mikeash commented Feb 2, 2023

@swift-ci please test linux platform

2 similar comments
@mikeash
Copy link
Contributor Author

mikeash commented Feb 3, 2023

@swift-ci please test linux platform

@mikeash
Copy link
Contributor Author

mikeash commented Mar 2, 2023

@swift-ci please test linux platform

…olved.

If there's a mismatch between the arguments we match and the arguments we actually have, we can end up indexing off the end of the argumentTypeNames vector. This can happen when an argument has a dependent generic type. Add a bounds check and print <unknown> when we're out of bounds to avoid crashing.

For correctness, we should match generic dependent types and add them to the arguments array, but we'll fix the crashes first.

rdar://104438524
@mikeash mikeash force-pushed the print-keypath-dependent-generic-type branch from 19d3a32 to 91dcf8d Compare March 2, 2023 18:46
@mikeash
Copy link
Contributor Author

mikeash commented Mar 2, 2023

@swift-ci please test and merge

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.

Runtime crash in AnyKeyPath.debugDescription when using @dynamicMemberLookup
3 participants