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-7571] class funcs of classes that inherits from NSObject can't access generics in closures on ARM #50113

Closed
swift-ci opened this issue Apr 30, 2018 · 2 comments
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 run-time crash Bug → crash: Swift code crashed during execution

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-7571
Radar rdar://problem/39868033
Original Reporter benpious (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

Xcode 9.3, various iOS 11.3.x versions on iPhone 6/6S models.

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

md5: 8abcd5c7821bc4db98eb6c76e7bdb536

Issue Description:

As the title. If you have a class that inherits from NSObject and is generic, the generic doesn't work in class functions that have closures that reference it. For example:

class C<T>: NSObject {
    
    let t: T
    
    init(t: T) {
        self.t = t
    }
    
    class func f<U>() -> (U) -> () where U: C  {
        return { (u: U) in 
            print(u.a) // this is fine because it doesn't involve `U` at all
            print(u.t) // this line crashes
            print(U.self) // this line would crash if it was reached
        }
    }
    
    class func g<U>(_ u: U) where U: C  {
        print(u.t)
    }

}

class Irrelevant {
    
}

let c = C(t: Irrelevant())
C.g(c) // fine
C.f()(c) // crashes on ARM

This code works on my Macbook Pro in a Playground or in the simulator, but on an iPhone 6+ or 6S, it crashes with EXEC_BAD_ACCESS, which is my basis for saying that this issue is only on ARM.

Note that `C.g` is fine because it does not have a closure in it at all.

@belkadan
Copy link
Contributor

belkadan commented May 1, 2018

Very strange. Thanks.

@swift-ci create

@aschwaighofer
Copy link
Member

No longer reproduces with a toolchain based on swift-4.2-branch or master (https://swift.org/download/#snapshots).

@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 run-time crash Bug → crash: Swift code crashed during execution
Projects
None yet
Development

No branches or pull requests

4 participants