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-4611] Runtime crash with nested type used as superclass generic argument #47188

Closed
swift-ci opened this issue Apr 17, 2017 · 1 comment
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 run-time crash Bug → crash: Swift code crashed during execution runtime The Swift Runtime

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-4611
Radar None
Original Reporter mlwoollard (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, RunTimeCrash, Runtime
Assignee None
Priority Medium

md5: cae105004f0afe8b0cad98e9ecd852b9

duplicates:

  • SR-5650 Remove parent field from type metadata

relates to:

  • SR-3779 Program with struct nested in generic struct crashes because of “cyclic metadata dependency”
  • SR-5432 Using nested type as a superclass generic parameter leads to a crash

Issue Description:

The following code compiles without warning but when run crashes instantiating Subclass instance, prior to entering Subclass.init. Would appear to be due to having nested struct A defined within Subclass and this being used as generic parameter. Refactoring struct A so its not nested and no crash. If this is not valid to use nested type as generic parameter like this should not the compiler give an error? If it is valid code the runtime crash should be fixed.

$ swiftc --version
Apple Swift version 3.1 (swiftlang-802.0.51 clang-802.0.41)

class Base<T> {}

class Subclass: Base<Subclass.A> {
    
    struct A {}
    
    override init() {
        super.init()
    }    
}

let _ = Subclass()
@belkadan
Copy link
Contributor

Yep, the nested type's runtime metadata has "parent" pointer that refers to the outer type, but the outer type has to record its superclass using the nested type.

@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 runtime The Swift Runtime
Projects
None yet
Development

No branches or pull requests

3 participants