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-9654] Swift 5: Compiler crashes on SILGen for subscript with autoclosure argument #52098

Closed
swift-ci opened this issue Jan 14, 2019 · 7 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. code coverage Area → source tooling: code coverage 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-9654
Radar rdar://problem/47254122
Original Reporter broadway_lamb (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

5.0-DEVELOPMENT-SNAPSHOT-2019-01-13-a

Apple Swift version 5.0-dev (LLVM ed64f75263, Clang e5012f3421, Swift 5a827a9)

Target: x86_64-apple-darwin18.2.0

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

md5: aaa569abe2db3ea87736204ac2ff957c

Issue Description:

This code crashes the compiler when code coverage is enabled:

struct S {
  subscript(i: Int, autoclosure: @autoclosure () ->  Int) -> Int {
    get {
      return 0
    }
    set {

    }
  }
}

I am using the latest (5.0-DEVELOPMENT-SNAPSHOT-2019-01-13-a) snapshot.

The SPM project to reproduce the issue: https://github.com/broadwaylamb/CompilerCrasherAutoclosureSubscript

Run:

$ swift build
$ swift test --enable-code-coverage

--enable-code-coverage is important.

@belkadan
Copy link
Contributor

cc @vedantk, @jckarter

@vedantk
Copy link
Member

vedantk commented Jan 14, 2019

When this program is built with the `-enable-testing` flag, the swift compiler synthesizes a top-level with an invalid source location. This confuses the coverage pass, which expects valid source locations on decls always.

It probably doesn’t make sense to fake a source location, so I added a defensive check in #21854

@swift-ci
Copy link
Collaborator Author

Comment by Sergej Jaskiewicz (JIRA)

@vedantk awesome, thank you!

@swift-ci
Copy link
Collaborator Author

Comment by Sergej Jaskiewicz (JIRA)

@vedantk I was wondering will this make it into Swift 5?

@vedantk
Copy link
Member

vedantk commented Jan 15, 2019

At this point swift-5.0-branch isn’t changing very much. I’m not sure whether or not this change is a candidate for it.

@swift-ci
Copy link
Collaborator Author

Comment by Sergej Jaskiewicz (JIRA)

@vedantk that is unfortunate, since it is clearly a regression, the same code works just fine with Swift 4.

@belkadan
Copy link
Contributor

Bob ended up pulling it in here: #22798

@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. code coverage Area → source tooling: code coverage 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