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-10590] Compiler crash with key paths and generics #52990

Closed
natecook1000 opened this issue May 1, 2019 · 12 comments
Closed

[SR-10590] Compiler crash with key paths and generics #52990

natecook1000 opened this issue May 1, 2019 · 12 comments
Assignees
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 key paths Feature: key paths (both native and Objective-C) run-time crash Bug → crash: Swift code crashed during execution

Comments

@natecook1000
Copy link
Member

Previous ID SR-10590
Radar rdar://problem/50968433
Original Reporter @natecook1000
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, KeyPaths, RunTimeCrash
Assignee @natecook1000
Priority Medium

md5: ea7bb338efd5374a19235a786422ebb6

relates to:

  • SR-10117 EXC_BAD_INSTRUCTION in playground

Issue Description:

Trying to compile this code crashes the compiler:

struct Container<Base, Value, Content>
    where Base: Collection
{
    var base: Base
    var elementPath: KeyPath<Base.Element, Value>
    var content: (Value) -> Content
}

let x = Container(base: 1...10, elementPath: \.bitWidth) {
    return String($0, radix: 2)
} 

Crash output in the attached crash.txt. This is in swiftlang-1100.8.25.5 clang-1100.0.15.2.

@theblixguy
Copy link
Collaborator

This doesn't crash for me on Swift 5.1 (near master).

@belkadan
Copy link
Contributor

belkadan commented May 1, 2019

Swift 5.1 isn't "near-master", it's a separate branch. (I'm not sure "near-master" is a real phrase. I use it when I try something with master but haven't actually pulled from master in a while.)

@theblixguy
Copy link
Collaborator

Oops. Thanks for clarifying - that’s what I wanted to say (haven’t actually tried with 5.1 snapshot or a compiler built from 5.1 branch, but have tried with a build from master which I recently checked out).

@belkadan
Copy link
Contributor

belkadan commented May 1, 2019

Anyway, this is a run-time crash, not a compiler crash. It sounds a lot like SR-10117, but that's not supposed to have been fixed yet.

@belkadan
Copy link
Contributor

belkadan commented May 1, 2019

@mikeash, @jckarter, did anything change here recently?

@jckarter
Copy link
Member

jckarter commented May 1, 2019

Not to my knowledge. That particular crash seems to be sensitive to JIT vs AOT mode, which might be partially at play here. It looks like Nate was executing this from script or integrated REPL mode based on the backtrace.

@natecook1000
Copy link
Member Author

Ack, sorry to mix up the compiler and run-time crash. This was run using `swift filename` from the command line — when I compile first and then run, it executes cleanly.

@jckarter
Copy link
Member

This looks like an LLVM JIT bug; for some reason, the indirect reference to the resilient key path descriptor is getting misaligned. This seems to work around it: #24944 I've sent a bug Lang's way in the meantime.

@compnerd
Copy link
Collaborator

@jckarter is there a LLVM PR this issue?

@jckarter
Copy link
Member

@compnerd I sent it to Lang via Radar, sorry.

The workaround is merged now, so this should be fixed in future snapshots.

@jckarter
Copy link
Member

The fix should be in the new Swift 5.1 snapshots now.

@jckarter
Copy link
Member

Lang fixed the underlying JIT bug in LLVM r362139.

@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 key paths Feature: key paths (both native and Objective-C) run-time crash Bug → crash: Swift code crashed during execution
Projects
None yet
Development

No branches or pull requests

6 participants