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-8084] FileHandle convenience initializer crashes with EXC_GUARD #3669

Closed
swift-ci opened this issue Jun 22, 2018 · 0 comments
Closed

[SR-8084] FileHandle convenience initializer crashes with EXC_GUARD #3669

swift-ci opened this issue Jun 22, 2018 · 0 comments

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-8084
Radar None
Original Reporter Vatsal Manot (JIRA User)
Type Bug
Status Closed
Resolution Invalid
Environment

Swift 4.2, Xcode 10 beta 1.

Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug
Assignee None
Priority Medium

md5: 6729a179f83c8fc400b8454a146e0877

Issue Description:

import Foundation

public enum FileAccessMode
{
    case read
    case write
    case update
}

extension FileHandle
{
    public convenience init(forURL url: URL, accessMode mode: FileAccessMode) throws
    {
        switch mode
        {
            case .read:
                try self.init(forReadingFrom: url)
            case .write:
                try self.init(forWritingTo: url)
            case .update:
                try self.init(forUpdating: url)
        }
    }
}

try! FileHandle(forReadingFrom: URL(fileURLWithPath: "/Applications/Chess.app/Contents/MacOS/Chess")) // does not crash

try! FileHandle(forURL: URL(fileURLWithPath: "/Applications/Chess.app/Contents/MacOS/Chess"), accessMode: .read) // crashes with EXC_GUARD

Crashes unpredictably. Run multiple times to reproduce.

@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

1 participant