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-10488] Pattern matching tuple in Xcode 10.2 results in EXC_BAD_INSTRUCTION #52888

Closed
swift-ci opened this issue Apr 15, 2019 · 2 comments
Closed
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software regression run-time crash Bug → crash: Swift code crashed during execution swift 5.0

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-10488
Radar rdar://49903264
Original Reporter dikovitsky.s (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

Xcode 10.2, macOS Mojave 10.14.4

Additional Detail from JIRA
Votes 4
Component/s Compiler
Labels Bug, 5.0Regression, RunTimeCrash
Assignee None
Priority Medium

md5: 31c65f6d6335f8d067fc60118d611436

Issue Description:

func failingFunc() {
    enum TestError {
        case connectivity(url: URL, void: Void)
    }
    let url = URL(string: "https://google.com")!
    let testError = TestError.connectivity(url: url, void: ())


    switch testError {
    case let .connectivity(value) where false:
        break
    case .connectivity:
        break
    }
}

failingFunc()

Reproduce rate is 100%.

Running this function will result in EXC_BAD_INSTRUCTION. Enabled zombies print following:

-[CFURL release]: message sent to deallocated instance 0x6000014e3330

The problem arises, when we have a case in enum with 2 or more associated values and one of them is URL or URLRequest (could not reproduce with other types). Also, we must have at least two same cases in switch which will be executed (changing `where false` to `where true` will not result in crash), and we have to refer to associated values as a tuple `let .connectivity(value)`, not separate values `let .connectivity(url, void)`.

Running this func in Xcode 10.1 results in no crash.

@bobergj
Copy link

bobergj commented May 16, 2019

We encounter a similar crash in code built with Xcode 10.2.1 (10E1001), not related to URL and URLRequest, but another class defined in Objective-C. It seems that the Swift compiler does not insert the correct retain/release instructions when referring to associated values as a tuple in a switch case clause.

@CodaFi
Copy link
Member

CodaFi commented May 11, 2020

This appears to have been resolved by #24809

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 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. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software regression run-time crash Bug → crash: Swift code crashed during execution swift 5.0
Projects
None yet
Development

No branches or pull requests

4 participants