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-8284] Crash: EXC_BAD_ACCESS when calling an implicitly mutating method on a protocol defined with conditional conformance to a class type #50815

Open
swift-ci opened this issue Jul 17, 2018 · 1 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

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-8284
Radar None
Original Reporter jaredsinclair (JIRA User)
Type Bug

Attachment: Download

Environment

Swift 4.1 and Xcode 9
or
Swift 4.2 and Xcode 10

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash
Assignee None
Priority Medium

md5: 183301533c6e47f0697a51f2e8ae01c7

Issue Description:

Running the following snippet in an Xcode Playground will crash at runtime for both Swift 4.1 and 4.2:

class SuperClass {}

protocol Crashable where Self: SuperClass {
     func crashMe(foo: String?)
}

class MyClass: SuperClass, Crashable {
    private var someProperty: String?
    
    func crashMe(foo: String?) {
        self.someProperty = foo // EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
    }
}

func triggerACrash(using crashable: Crashable) {
    crashable.crashMe(foo: "foo")
}

triggerACrash(using: MyClass())

The crash can be resolved either by changing the protocol definition to require `class` instead of a specific class type, or by changing the trigger method argument type to `SuperClass & Crashable`.

@belkadan
Copy link
Contributor

Superclass constraints on protocols aren't really supported yet; we just failed to ban them in Swift 4.1 and 4.2. @slavapestov, is this case covered by your recent work?

@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
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
Projects
None yet
Development

No branches or pull requests

3 participants