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-14880] [AutoDiff] Crash caused by storing a closure into a variable member of a struct #57227

Closed
vojtamolda opened this issue Jul 6, 2021 · 2 comments
Assignees
Labels
assertion failure Bug → crash: An assertion failure AutoDiff 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 SILGen Area → compiler: The SIL generation stage swift for tensorflow

Comments

@vojtamolda
Copy link
Contributor

Previous ID SR-14880
Radar rdar://problem/80278725
Original Reporter @vojtamolda
Type Bug

Attachment: Download

Environment

macOS 11.4 with Swift development snapshot 2021-06-13:

Apple Swift version 5.5-dev (LLVM 75998a7b14501e1, Swift 38a8b008bc66b11)
Target: x86_64-apple-macosx11.0
Additional Detail from JIRA
Votes 0
Component/s Compiler, Swift for TensorFlow
Labels Bug, AutoDiff
Assignee @rxwei
Priority Medium

md5: 7e18065aaef6b8633a9c9c49581ccbd4

Issue Description:

Hello all,

I think I stumbled upon a in bug in the compiler. The code chunk below crashes with a failed assertion. The stack trace is attached.

I did some experimentation and the trigger seems to be storing a multi (two and more) argument `@differentiable` closure as `var` member of a struct. Single argument closures work well and non-mutable members, i.e. `let` works too.

import _Differentiation


typealias FunctionOfX = (@differentiable(reverse) (Double) -> Double)
struct Struct1Let { // Works
    let f: FunctionOfX
}
var s1l = Struct1Let() { $0 }

struct Struct1Var { // Works
    var f: FunctionOfX
}
var s1v = Struct1Var() { $0 }


typealias FunctionOfXY = (@differentiable(reverse) (Double, Double) -> Double)

struct Struct2Let { // Works
    let f: FunctionOfXY
}
var s2l = Struct2Let() { $0 * $1 }

struct Struct2Var { // Crashes
    var f: FunctionOfXY
}
var s2v = Struct2Var() { $0 * $1 }
@typesanitizer
Copy link

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@BradLarson
Copy link
Collaborator

This no longer reproduces with top-of-tree Swift, so I'll close it out.

@AnthonyLatsis AnthonyLatsis added crash Bug: A crash, i.e., an abnormal termination of software SILGen Area → compiler: The SIL generation stage assertion failure Bug → crash: An assertion failure labels May 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assertion failure Bug → crash: An assertion failure AutoDiff 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 SILGen Area → compiler: The SIL generation stage swift for tensorflow
Projects
None yet
Development

No branches or pull requests

4 participants