Skip to content
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

[SR-277] Crash on sortInPlace, on App Store builds only #42899

Closed
swift-ci opened this issue Dec 17, 2015 · 2 comments
Closed

[SR-277] Crash on sortInPlace, on App Store builds only #42899

swift-ci opened this issue Dec 17, 2015 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-277
Radar None
Original Reporter mjswensen (JIRA User)
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s
Labels Bug
Assignee None
Priority Medium

md5: f53239eaaab6859b6e8c0abedfa2b145

Issue Description:

It would appear that in Swift 2.1, in the App Store build compiled with Xcode 7.2, the `sortInPlace( isOrderedBefore: (Int, Int) -> Bool )` has an error in the compiled code that causes a crash. Curiously, the problem manifests itself only in App Store builds, making it difficult to detect for development teams. We believe that something may be happening in the archiving process previous to uploading a build to iTunesConnect, as the problem does not occur when building locally in release mode.

We found the problem to occur with 17-20 or more elements in the array to be sorted (that is, the problem starts to occur around 17-20 elements and always occurs with more than 20 elements). This arbitrary number was confirmed independently when we came across this StackOverflow question outlining the same issue that we were having (see the end of the question): http://stackoverflow.com/questions/33444460/swift-2-1-error-sorting-in-place-only-on-release-builds . We suspect the number to be related to the following lines in the Swift source code:

// Insertion sort is better at handling smaller regions.
if range.count < 20 {
_insertionSort(&elements, range ${", &isOrderedBefore" if p else ""})
return
}

It is also worth mentioning that Bitcode is disabled.

Here is the relevant portion of our code:

documents.sortInPlace({ (doc1, doc2) -> Bool in
    let compare = doc1.document.saved.compare(doc2.document.saved)
    return compare != NSComparisonResult.OrderedAscending
})

(The linked StackOverflow question also provides a reproducible base case.)

The current workaround is to refactor the code to use `sort` instead of `sortInPlace`.

Is this the correct place to report this issue?

@aschwaighofer
Copy link
Member

There was a known issue in Xcode 7.1 see the 7.1.1 section of https://developer.apple.com/library/ios/releasenotes/DeveloperTools/RN-Xcode/Chapters/xc7_release_notes.html

If Xcode 7.2 does not fix your issue please file a bug at https://bugreport.apple.com/

Thank you.

@Dante-Broggi
Copy link
Contributor

Resolving this as it is old and aschwaighofer@apple.com (JIRA User) said that any followup should go to the apple bugs.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.
Projects
None yet
Development

No branches or pull requests

3 participants