Skip to content

[SR-13305] Derivative function protocol witness SILGen crash for non-wrt inout parameter #55745

@dan-zheng

Description

@dan-zheng
Previous ID SR-13305
Radar None
Original Reporter @dan-zheng
Type Bug
Status Closed
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s
Labels Bug
Assignee @dan-zheng
Priority Medium

md5: 5025ef37b09b0ab538d4ba0382ddf907

Issue Description:

import _Differentiation

protocol MyProtocol {
  @differentiable(wrt: weight)
  func execute(weight: Float, outputs: inout Float)
}

struct Impl: MyProtocol {
  func execute(weight: Float, outputs: inout Float) {
    outputs = weight
  }
}
$ swiftc sr-13305.swift
Assertion failed: (!array.empty() && "claiming next from empty array!"), function claimNext, file /Users/danielzheng/swift-bart/swift/lib/SILGen/SILGenPoly.cpp, line 112.
Stack dump:
...
1.  Swift version 5.3-dev (LLVM 7bfb26db929c00a, Swift 3263d261f1e42cf)
2.  While evaluating request ASTLoweringRequest(Lowering AST to SIL for file "sr-13305.swift")
3.  While generating SIL witness table protocol conformance to 'MyProtocol' (at sr-13305.swift:3:1) for type 'Impl' (declared at [sr-13305.swift:8:1 - line:12:1] RangeText="struct Impl: MyProtocol {
  func execute(weight: Float, outputs: inout Float) {
    outputs = weight
  }
")
4.  While generating protocol witness thunk SIL function "@AD__$s4main4ImplVAA10MyProtocolA2aDP7execute6weight7outputsySf_SfztFTW_jvp_SUU".
 for 'execute(weight:outputs:)' (at sr-13305.swift:9:3)
5.  While emitting reabstraction thunk in SIL function "@$sSfIegy_S2fIegyd_TR".
 for <<debugloc at "<compiler-generated>":0:0>>0  swift-frontend           0x0000000111aa5105 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  swift-frontend           0x0000000111aa40b8 llvm::sys::RunSignalHandlers() + 248
2  swift-frontend           0x0000000111aa5706 SignalHandler(int) + 262
3  libsystem_platform.dylib 0x00007fff6a3e15fd _sigtramp + 29
4  libsystem_platform.dylib 000000000000000000 _sigtramp + 18446603338733709856
5  libsystem_c.dylib        0x00007fff6a2b7808 abort + 120
6  libsystem_c.dylib        0x00007fff6a2b6ac6 err + 0
7  swift-frontend           0x000000010be046cd swift::SILResultInfo const& claimNext<swift::SILResultInfo>(llvm::ArrayRef<swift::SILResultInfo>&) + 93
8  swift-frontend           0x000000010be032e0 (anonymous namespace)::ResultPlanner::claimNextInnerResult((anonymous namespace)::ResultPlanner::PlanData&) + 32

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions