-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[5.1] Fix sub-scalar index distances in foreign UTF8 views #27477
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
[5.1] Fix sub-scalar index distances in foreign UTF8 views #27477
Conversation
(cherry picked from commit 0887299)
@swift-ci please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add test cases that failed before but are fixed with this change.
Previously, when this code was just trivially invoking the UTF8View, we didn't have to test all of these corner cases since the UTF8View itself was tested for sub-scalar indices. Since we have a fast-path alternative implementation, we need to craft the same kinds of corner case tests for that.
We have such tests on master, but they require another PR to expose the failure that we don't want to back port. I'll see about adding some more. |
…nd fix existing invalid NSString construction
@milseman so, I spent the last couple of hours trying to modify the StringIndex tests to catch this, and unfortunately it turns out to be surprisingly difficult to get good coverage on this because of all the (correct) pre/postconditions that blow up in other code paths. @kylemacomber pointed out that we can use the example from the crash in question though, so this at least gets us some signal without having to back port the other changes. |
@swift-ci please test |
Build failed |
Build failed |
0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, | ||
0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, | ||
0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, | ||
0xD800 }; | ||
return [NSString stringWithCharacters:chars length:1]; | ||
return [NSString stringWithCharacters:chars length:19]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😳
Can you bring this to master as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup!
(cherry picked from commit 0887299)
Fixes rdar://55736405