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-7969] appendingPathComponent on URL crashes #3677

Closed
swift-ci opened this issue Jun 11, 2018 · 5 comments
Closed

[SR-7969] appendingPathComponent on URL crashes #3677

swift-ci opened this issue Jun 11, 2018 · 5 comments

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-7969
Radar rdar://problem/41012203
Original Reporter smon (JIRA User)
Type Bug
Status Closed
Resolution Cannot Reproduce
Environment

Xcode Version: Version 10.0 beta (10L176w)

Swift Toolchain: Xcode 10.0

Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug
Assignee smon (JIRA)
Priority Medium

md5: 0997f8cab1e648649edd3509a06a4228

Issue Description:

While experimenting with Xcode 10 and the "Xcode 10.0" swift toolchain i encountered this.

It appears if i obtain a string by joining an empty array of strings, and then append it as a path-component on a URL, i get different results than when using a plain string.

I managed to create an example reproducing the issue:

import Foundation

let emptyStringArray: [String] = []
let nonEmptyStringArray: [String] = [""]

let url = URL(string: "http://example.org")
let fromEmptyStringArray: String = emptyStringArray.joined(separator: "/")
let fromNonEmptyStringArray: String = nonEmptyStringArray.joined(separator: "/")
let plainEmptyString = ""

// this works
url?.appendingPathComponent(plainEmptyString)
url?.appendingPathComponent("")

// this will crash
url?.appendingPathComponent(fromEmptyStringArray)
// Precondition failed: Index out of bounds: file /BuildRoot/Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-1000.0.16.7/src/swift/stdlib/public/core/StringStorage.swift, line 108

// this will crash:
url?.appendingPathComponent(fromNonEmptyStringArray)
// Precondition failed: Index out of bounds: file /BuildRoot/Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-1000.0.16.7/src/swift/stdlib/public/core/StringStorage.swift, line 108
@belkadan
Copy link

@swift-ci create

@milseman
Copy link
Mannequin

milseman mannequin commented Jul 11, 2018

This did not reproduce for me on Xcode 10 beta 3. smon (JIRA User), can you try with a more recent toolchain or beta?

@AnnaZaks
Copy link
Mannequin

AnnaZaks mannequin commented Aug 4, 2018

smon (JIRA User), Could you verify if the problem is fixed and if so move the JIRA to "Closed"?
Thanks!
Anna

@swift-ci
Copy link
Contributor Author

swift-ci commented Aug 4, 2018

Comment by Simon Anreiter (JIRA)

@AnnaZaks, just tried to reproduce the issue.

Everything seems to work now.

👍

@AnnaZaks
Copy link
Mannequin

AnnaZaks mannequin commented Aug 5, 2018

Thank you!

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants