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-9280] Compiler segfaults while typechecking #51752

Closed
swift-ci opened this issue Nov 16, 2018 · 1 comment
Closed

[SR-9280] Compiler segfaults while typechecking #51752

swift-ci opened this issue Nov 16, 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-9280
Radar rdar://problem/46129351
Original Reporter twof (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

Swift 4.2.1
Xcode 10.1

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

md5: 8e62418a529c60dcf8c60dc1bc80b86f

Issue Description:

You can find a repro under the `bugrepro` branch here
https://github.com/twof/iOSSQLiteTest/tree/bugrepro

I tried creating a minimal repro without any dependencies, but I couldn't. The project is pretty small though.

It began segfaulting when I changed `SQLiteModel.ID` to an optional and tried using the wrapped type of the optional in function bodies within the `Database` extension.

extension Database {
    func selectAll<M: SQLiteModel>(modelType: M.Type) throws -> [M] {
        return try selectFrom(
            modelType.modelName,
            block: M.init
        )
    }

    func select<M: SQLiteModel>(modelType: M.Type, withId id: M.ID.WrappedType) throws -> M? {
        return try selectFrom(M.modelName, whereExpr: "id=\(id)", block: M.init).first
    }

    func create<M: SQLiteModel>(model: M) throws -> M.ID.WrappedType {
        return try insertInto(M.modelName, values: model.asDictionary()) as! M.ID
    }

    func delete<M: SQLiteModel>(modelType: M.Type, withId id: M.ID.WrappedType) throws -> M? {
        let model = try select(modelType: modelType, withId: id)
        try deleteFrom(M.modelName, rowIds: [id])
        return model
    }
}

Code completion suggested `.WrappedType`, which I don't believe exists on Optional (edit: It does on OptionalType), but I selected it anyway, and that's when it segfaulted. It's definitely got something to do with the usage of WrappedType. The bug is fixed as soon as all instances of WrappedType are removed, and then as soon as one is brought back, it starts segfaulting again.

@hborla
Copy link
Member

hborla commented Jul 31, 2020

This is fixed in Swift 5.3. The compiler now reports several error messages with Fix-Its, and applying all of the Fix-Its fixes all of the errors.

Could you please verify using the latest Xcode 12 beta? Thank you!

@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

3 participants