Skip to content

[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

Merged

Conversation

Catfish-Man
Copy link
Contributor

(cherry picked from commit 0887299)

Fixes rdar://55736405

@Catfish-Man Catfish-Man requested a review from a team as a code owner October 2, 2019 00:24
@Catfish-Man Catfish-Man self-assigned this Oct 2, 2019
@airspeedswift
Copy link
Member

@swift-ci please test

Copy link
Member

@milseman milseman left a 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.

@Catfish-Man
Copy link
Contributor Author

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
@Catfish-Man
Copy link
Contributor Author

@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.

@Catfish-Man
Copy link
Contributor Author

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented Oct 3, 2019

Build failed
Swift Test OS X Platform
Git Sha - 69eab55

@swift-ci
Copy link
Contributor

swift-ci commented Oct 3, 2019

Build failed
Swift Test Linux Platform
Git Sha - 69eab55

@milseman milseman changed the title Fix sub-scalar index distances in foreign UTF8 views [5.1] Fix sub-scalar index distances in foreign UTF8 views Oct 3, 2019
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];
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup!

@Catfish-Man Catfish-Man merged commit 60cfb65 into swiftlang:swift-5.1-branch Oct 3, 2019
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.

4 participants