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-13009] PAT constraint in superclass initializer causes Segmentation fault: 11 in generic subclass #55454

Closed
swift-ci opened this issue Jun 14, 2020 · 5 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-13009
Radar None
Original Reporter danielhall (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment
  • Xcode 11.5 running on macOS Catalina.

  • Current version of Swift Playgrounds on iPad Pro

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

md5: ea8a56c0f958568461149465ff10c821

Issue Description:

import Combine{{ }}

class Test<Value> {

{{ @published private var value: Value}}

{{ init<InputPublisher: Publisher>(initialValue: Value, inputPublisher: InputPublisher) { }}

{{ value = initialValue}}

}

}

// This compiles

class OK: Test<String> {

{{ init() {}}

{{ super.init(initialValue: "", inputPublisher: ["a", "b", "c"].publisher)}}

}

}

// Segmentation fault: 11

class UhOh<T>: Test<String> {

{{ init() {}}

{{ super.init(initialValue: "", inputPublisher: ["a", "b", "c"].publisher)}}

}

}

Removing the generic component from the subclass makes it compile, as noted.

Changing the superclass initializer to take an AnyPublisher<Value, Never> parameter instead of a constrained InputPublisher: Publisher parameter also makes it compile.

@theblixguy
Copy link
Collaborator

The code above is missing a few closing braces, but regardless it doesn't compile:

/Users/spare/Desktop/test.swift:5:8: error: generic parameter 'Input' is not used in function signature
  init<Input, InputPublisher: Publisher>(initialValue: Value, inputPublisher: InputPublisher) {
       ^

Although once I remove the unused generic parameter, the code compiles fine on master, so I think the crash is fixed.

@swift-ci
Copy link
Collaborator Author

Comment by Daniel Hall (JIRA)

@theblixguy Oh no! Sorry about the non-compiling example — I had some copy-paste / Jira formatting issues. I updated the sample code above and pasted it into an Xcode 11.5 project to verify that it reproduces the Segmentation fault 11 error

@theblixguy
Copy link
Collaborator

No worries! Could you verify using a development snapshot from swift.org?

@swift-ci
Copy link
Collaborator Author

Comment by Daniel Hall (JIRA)

Nice! No Segmentation fault using the latest development snapshot. My original use case that I condensed to a smaller reproducible example for this bug also also compiles successfully with the latest development snapshot. Looks like it must have already been fixed then ��

@slavapestov
Copy link
Member

I can confirm this is fixed in a 5.3 development snapshot.

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

No branches or pull requests

4 participants