Skip to content

SR-10689: Fix bugs of DataProtocol's firstRange(of:in:)/lastRange(of:in:). #2499

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
Jun 14, 2021

Conversation

YOCKOW
Copy link
Member

@YOCKOW YOCKOW commented Sep 1, 2019

DataProtocol's firstRange(of:in:) and lastRange(of:in:) return a wrong value or crash under some conditions because they handle indices incorrectly.
This PR fixes the issue.

Resolves SR-10689.


Note:
SR-10689 also says "lastRange(of:) returns firstRange(of:in:)", however, it has been already fixed by #2310.

@spevans
Copy link
Contributor

spevans commented Sep 1, 2019

@swift-ci test

@YOCKOW
Copy link
Member Author

YOCKOW commented Feb 17, 2020

Rebased to resolve conflicts.

@spevans
Copy link
Contributor

spevans commented Feb 17, 2020

@swift-ci test

@YOCKOW
Copy link
Member Author

YOCKOW commented Feb 21, 2020

The failures seem to be unrelated to this PR, don't they...?

@CodaFi
Copy link
Contributor

CodaFi commented Apr 15, 2020

@swift-ci test

1 similar comment
@CodaFi
Copy link
Contributor

CodaFi commented Apr 15, 2020

@swift-ci test

@YOCKOW
Copy link
Member Author

YOCKOW commented Apr 16, 2020

@CodaFi

Thank you for running tests.

The error on macOS seems to be unrelated.

@CodaFi
Copy link
Contributor

CodaFi commented Apr 19, 2020

@swift-ci test

@YOCKOW
Copy link
Member Author

YOCKOW commented Apr 24, 2020

The failure on Linux seems to be caused by LLDB...

@YOCKOW
Copy link
Member Author

YOCKOW commented Jun 26, 2020

I believe this is not stale... so rebased.
(Or we should wait for generalized "Collection Matchers"?)

@spevans
Copy link
Contributor

spevans commented Jun 26, 2020

@swift-ci test

@YOCKOW
Copy link
Member Author

YOCKOW commented Jun 28, 2020

@spevans Thank you for rerunning tests.


The error seems to be unrelated.

/home/buildnode/jenkins/workspace/swift-corelibs-foundation-PR-Linux/swift/validation-test/StdlibUnittest/RaceTest.swift:116:11: error: CHECK: expected string not found in input
16:55:33 // CHECK: [ OK ] Race.closure
16:55:33 ^
16:55:33 :17:1: note: scanning from here
16:55:33 stderr>>> CRASHED: SIGSEGV
16:55:33 ^
16:55:33 :19:3: note: possible intended match here
16:55:33 [ FAIL ] Race.closure
16:55:33 ^
16:55:33
16:55:33 --

@spevans
Copy link
Contributor

spevans commented Jun 28, 2020

@swift-ci test linux

@YOCKOW
Copy link
Member Author

YOCKOW commented Jul 3, 2020

@spevans Thank you again. At last tests have passed.

kylemacomber pushed a commit to swiftlang/swift that referenced this pull request Aug 7, 2020
@YOCKOW
Copy link
Member Author

YOCKOW commented Aug 9, 2020

Finally PR for SDK Overlay (swift#28639) has been merged.
I expect this PR is also ready to be merged.

@juozasvalancius
Copy link

I've just discovered that the previous implementation also had bugs in the returned length of the range.
So it's probably a good idea to add tests for that too.

Here is a case that returns shorter range than the given input in Xcode 11.6 (11E708):

import Foundation
let data = Data([1, 2, 3, 4, 5, 6])
let search = Data([2, 3, 9])
data.firstRange(of: search, in: 0 ..< 5) // returns 1..<2, should be nil

@YOCKOW YOCKOW changed the base branch from master to main October 4, 2020 05:21
@YOCKOW
Copy link
Member Author

YOCKOW commented Oct 4, 2020

No conflicts even after the base branch was changed from master to main.

@MaxDesiatov MaxDesiatov requested a review from spevans October 4, 2020 08:21
@MaxDesiatov MaxDesiatov requested a review from millenomi October 4, 2020 08:21
millenomi pushed a commit that referenced this pull request Nov 11, 2020
@YOCKOW

This comment has been minimized.

@YOCKOW
Copy link
Member Author

YOCKOW commented May 18, 2021

Confirmation


@millenomi Could you review this PR (and/or #2993) at your convenience?

@CodaFi
Copy link
Contributor

CodaFi commented Jun 9, 2021

@swift-ci test

@YOCKOW
Copy link
Member Author

YOCKOW commented Jun 10, 2021

@CodaFi
Thnak you for rerunning tests.
All tests have passed again.

@CodaFi
Copy link
Contributor

CodaFi commented Jun 12, 2021

I would like sign offs from some core maintainers here.

@millenomi @spevans

@millenomi millenomi merged commit b7bfec5 into swiftlang:main Jun 14, 2021
@millenomi
Copy link
Contributor

Done.

@YOCKOW
Copy link
Member Author

YOCKOW commented Jun 14, 2021

@millenomi Thank you for your approval.

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.

5 participants