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-8389] Segmentation fault: escaping closure with generic type as a parameter for a function variable #50916

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

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-8389
Radar None
Original Reporter samh (JIRA User)
Type Bug
Environment

High Sierra 10.13.5

XCode 9.4.1

iOS 10.0

Swift 4

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

md5: 66feb96a5410e634be3137b35b054a9c

Issue Description:

So I'm not completely sure if this is something the compiler should be able to due, but filing this because I'm not sure why it shouldn't be able to do this...

var doLoad: ((@escaping (([T]) -> Void)) -> Void)? // Swift compiler error
func load() {
    if state == .empty || state == .loaded {
        state = .loading
        doLoad? { items in
            self.update(items: items)
        }
    }
}

Build log says:

"1. While emitting IR for source file XX/XX.swift"

Command failed due to signal: Segmentation fault: 11

@belkadan
Copy link
Contributor

Whether it should be an error or not, the compiler should never crash, so thank you! I think you're missing some of your example, though: what's T?

@swift-ci
Copy link
Collaborator Author

Comment by Samuel Huang (JIRA)

T is of type(s) Any, the implementation is a reloadable, paged collection for tableviews/collectionviews

Since coming across this issue, I've now updated the method signature to to:

    var doLoad: ((((_ items: [T]) -> Void)?) -> Void)?
    func load() {
        if state == .empty || state == .loaded {
            state = .loading
            doLoad? { items in
                self.update(items: items)
            }
        }
    }

and now it works fine...

@belkadan
Copy link
Contributor

We'd still like to track down the original failure, but we need a self-contained test case to do that. Just this bit of code isn't enough.

@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