Closed
Description
Previous ID | SR-15566 |
Radar | None |
Original Reporter | @BradLarson |
Type | Bug |
Status | Resolved |
Resolution | Done |
Additional Detail from JIRA
Votes | 0 |
Component/s | Compiler |
Labels | Bug, AutoDiff |
Assignee | @rxwei |
Priority | Medium |
md5: cc857cf6edb138b26261ab8a61df5c82
Issue Description:
Starting with the 2021-12-04 nightly snapshot, certain differentiable functions that involve struct or local `var`s cause an assertion failure of "location is a VarDecl, but SILDebugVariable is empty". A simple reproducer is as follows:
import _Differentiation
public struct Test: Differentiable {
public var v1: [[Float]]
@differentiable(reverse)
public init(v1: [[Float]]) {
if v1.count != 2 {
fatalError("Mismatched counts")
}
self.v1 = v1
}
}
Place the above by itself in a file and build with swiftc file.swift to trigger this failure. The full assertion text is as follows:
Assertion failed: ((!dyn_cast_or_null<VarDecl>(Loc.getAsASTNode<Decl>()) || Var) && "location is a VarDecl, but SILDebugVariable is empty"), function createAllocStack, file SILBuilder.h, line 389.
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace.
Stack dump:
0. Program arguments: /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2021-12-02-a.xctoolchain/usr/bin/swift-frontend -frontend -c -primary-file /Users/bradlarson/Development/DifferentiableSwift/CompilerBugs/VarDeclCrasher/VarDeclCrasher/main.swift -emit-dependencies-path /Users/bradlarson/Library/Developer/Xcode/DerivedData/VarDeclCrasher-ahvubcfxipupclheemrxtzypaszf/Build/Intermediates.noindex/VarDeclCrasher.build/Debug/VarDeclCrasher.build/Objects-normal/x86_64/main.d -emit-reference-dependencies-path /Users/bradlarson/Library/Developer/Xcode/DerivedData/VarDeclCrasher-ahvubcfxipupclheemrxtzypaszf/Build/Intermediates.noindex/VarDeclCrasher.build/Debug/VarDeclCrasher.build/Objects-normal/x86_64/main.swiftdeps -serialize-diagnostics-path /Users/bradlarson/Library/Developer/Xcode/DerivedData/VarDeclCrasher-ahvubcfxipupclheemrxtzypaszf/Build/Intermediates.noindex/VarDeclCrasher.build/Debug/VarDeclCrasher.build/Objects-normal/x86_64/main.dia -target x86_64-apple-macos11.3 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk -I /Users/bradlarson/Library/Developer/Xcode/DerivedData/VarDeclCrasher-ahvubcfxipupclheemrxtzypaszf/Build/Products/Debug -F /Users/bradlarson/Library/Developer/Xcode/DerivedData/VarDeclCrasher-ahvubcfxipupclheemrxtzypaszf/Build/Products/Debug -enable-testing -g -module-cache-path /Users/bradlarson/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -swift-version 5 -enforce-exclusivity=checked -Onone -D DEBUG -new-driver-path /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2021-12-02-a.xctoolchain/usr/bin/swift-driver -serialize-debugging-options -resource-dir /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2021-12-02-a.xctoolchain/usr/lib/swift -enable-anonymous-context-mangled-names -Xcc -I/Users/bradlarson/Library/Developer/Xcode/DerivedData/VarDeclCrasher-ahvubcfxipupclheemrxtzypaszf/Build/Intermediates.noindex/VarDeclCrasher.build/Debug/VarDeclCrasher.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/bradlarson/Library/Developer/Xcode/DerivedData/VarDeclCrasher-ahvubcfxipupclheemrxtzypaszf/Build/Intermediates.noindex/VarDeclCrasher.build/Debug/VarDeclCrasher.build/VarDeclCrasher-generated-files.hmap -Xcc -I/Users/bradlarson/Library/Developer/Xcode/DerivedData/VarDeclCrasher-ahvubcfxipupclheemrxtzypaszf/Build/Intermediates.noindex/VarDeclCrasher.build/Debug/VarDeclCrasher.build/VarDeclCrasher-own-target-headers.hmap -Xcc -I/Users/bradlarson/Library/Developer/Xcode/DerivedData/VarDeclCrasher-ahvubcfxipupclheemrxtzypaszf/Build/Intermediates.noindex/VarDeclCrasher.build/Debug/VarDeclCrasher.build/VarDeclCrasher-all-target-headers.hmap -Xcc -iquote -Xcc /Users/bradlarson/Library/Developer/Xcode/DerivedData/VarDeclCrasher-ahvubcfxipupclheemrxtzypaszf/Build/Intermediates.noindex/VarDeclCrasher.build/Debug/VarDeclCrasher.build/VarDeclCrasher-project-headers.hmap -Xcc -I/Users/bradlarson/Library/Developer/Xcode/DerivedData/VarDeclCrasher-ahvubcfxipupclheemrxtzypaszf/Build/Products/Debug/include -Xcc -I/Users/bradlarson/Library/Developer/Xcode/DerivedData/VarDeclCrasher-ahvubcfxipupclheemrxtzypaszf/Build/Intermediates.noindex/VarDeclCrasher.build/Debug/VarDeclCrasher.build/DerivedSources-normal/x86_64 -Xcc -I/Users/bradlarson/Library/Developer/Xcode/DerivedData/VarDeclCrasher-ahvubcfxipupclheemrxtzypaszf/Build/Intermediates.noindex/VarDeclCrasher.build/Debug/VarDeclCrasher.build/DerivedSources/x86_64 -Xcc -I/Users/bradlarson/Library/Developer/Xcode/DerivedData/VarDeclCrasher-ahvubcfxipupclheemrxtzypaszf/Build/Intermediates.noindex/VarDeclCrasher.build/Debug/VarDeclCrasher.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -working-directory/Users/bradlarson/Development/DifferentiableSwift/CompilerBugs/VarDeclCrasher -module-name VarDeclCrasher -target-sdk-version 11.3.0 -o /Users/bradlarson/Library/Developer/Xcode/DerivedData/VarDeclCrasher-ahvubcfxipupclheemrxtzypaszf/Build/Intermediates.noindex/VarDeclCrasher.build/Debug/VarDeclCrasher.build/Objects-normal/x86_64/main.o -index-store-path /Users/bradlarson/Library/Developer/Xcode/DerivedData/VarDeclCrasher-ahvubcfxipupclheemrxtzypaszf/Index/DataStore -index-system-modules
1. Apple Swift version 5.6-dev (LLVM 45a3cc180a9a385, Swift 8a7ca32cf0f903f)
2. Compiling with the current language version
3. While evaluating request ExecuteSILPipelineRequest(Run pipelines { Mandatory Diagnostic Passes + Enabling Optimization Passes } on SIL for VarDeclCrasher)
4. While running pass #​142 SILModuleTransform "Differentiation".
5. While processing // differentiability witness for Test.init(v1:)
sil_differentiability_witness [serialized] [reverse] [parameters 0] [results 0] @$s14VarDeclCrasher4TestV2v1ACSaySaySfGG_tcfC : $@convention(method) (@owned Array<Array<Float>>, @thin Test.Type) -> @owned Test {
}
on SIL function "@$s14VarDeclCrasher4TestV2v1ACSaySaySfGG_tcfC".
for 'init(v1:)' (at /Users/bradlarson/Development/DifferentiableSwift/CompilerBugs/VarDeclCrasher/VarDeclCrasher/main.swift:7:12)
6. While generating VJP for SIL function "@$s14VarDeclCrasher4TestV2v1ACSaySaySfGG_tcfC".
for 'init(v1:)' (at /Users/bradlarson/Development/DifferentiableSwift/CompilerBugs/VarDeclCrasher/VarDeclCrasher/main.swift:7:12)
7. While generating pullback for SIL function "@$s14VarDeclCrasher4TestV2v1ACSaySaySfGG_tcfC".
for 'init(v1:)' (at /Users/bradlarson/Development/DifferentiableSwift/CompilerBugs/VarDeclCrasher/VarDeclCrasher/main.swift:7:12)
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0 swift-frontend 0x000000010b058967 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 39
1 swift-frontend 0x000000010b057b85 llvm::sys::RunSignalHandlers() + 85
2 swift-frontend 0x000000010b058fa0 SignalHandler(int) + 288
3 libsystem_platform.dylib 0x00007fff20367d7d _sigtramp + 29
4 libsystem_platform.dylib 0x0000000000000089 _sigtramp + 18446603339975721769
5 libsystem_c.dylib 0x00007fff20277406 abort + 125
6 libsystem_c.dylib 0x00007fff202767d8 err + 0
7 swift-frontend 0x000000010b0bb493 swift::SILBuilder::createAllocStack(swift::SILLocation, swift::SILType, llvm::Optional<swift::SILDebugVariable>, bool, bool) (.cold.2) + 35
8 swift-frontend 0x000000010647c2c1 swift::SILBuilder::createAllocStack(swift::SILLocation, swift::SILType, llvm::Optional<swift::SILDebugVariable>, bool, bool) + 673
9 swift-frontend 0x0000000106aabe04 swift::autodiff::TangentBuilder::emitAdd(swift::SILLocation, swift::SILValue, swift::SILValue) + 468
10 swift-frontend 0x0000000106aa03f6 swift::autodiff::PullbackCloner::Implementation::accumulateAdjointsDirect(swift::autodiff::AdjointValue, swift::autodiff::AdjointValue, swift::SILLocation) + 438
11 swift-frontend 0x0000000106a99216 swift::autodiff::PullbackCloner::Implementation::addAdjointValue(swift::SILBasicBlock*, swift::SILValue, swift::autodiff::AdjointValue, swift::SILLocation) + 1286
12 swift-frontend 0x0000000106a9d607 swift::autodiff::PullbackCloner::Implementation::visit(swift::SILInstruction*) + 167
13 swift-frontend 0x0000000106a996bb swift::autodiff::PullbackCloner::Implementation::visitSILBasicBlock(swift::SILBasicBlock*) + 811
14 swift-frontend 0x0000000106a96aa7 swift::autodiff::PullbackCloner::Implementation::run() + 6967
15 swift-frontend 0x0000000106a94f42 swift::autodiff::PullbackCloner::run() + 18
16 swift-frontend 0x0000000106ab6308 swift::autodiff::VJPCloner::Implementation::run() + 1528
17 swift-frontend 0x0000000106ab69c2 swift::autodiff::VJPCloner::run() + 18
18 swift-frontend 0x0000000106bdc2b2 (anonymous namespace)::DifferentiationTransformer::canonicalizeDifferentiabilityWitness(swift::SILDifferentiabilityWitness*, swift::autodiff::DifferentiationInvoker, swift::IsSerialized_t) + 6882
19 swift-frontend 0x0000000106bd9dc8 (anonymous namespace)::Differentiation::run() + 1432
20 swift-frontend 0x0000000106c35581 swift::SILPassManager::runModulePass(unsigned int) + 689
21 swift-frontend 0x0000000106c3a57a swift::SILPassManager::execute() + 634
22 swift-frontend 0x0000000106c32168 swift::SILPassManager::executePassPipelinePlan(swift::SILPassPipelinePlan const&) + 72
23 swift-frontend 0x0000000106c320f1 swift::ExecuteSILPipelineRequest::evaluate(swift::Evaluator&, swift::SILPipelineExecutionDescriptor) const + 65
24 swift-frontend 0x0000000106c52c7d swift::SimpleRequest<swift::ExecuteSILPipelineRequest, std::__1::tuple<> (swift::SILPipelineExecutionDescriptor), (swift::RequestFlags)1>::evaluateRequest(swift::ExecuteSILPipelineRequest const&, swift::Evaluator&) + 29
25 swift-frontend 0x0000000106c3d121 llvm::Expected<swift::ExecuteSILPipelineRequest::OutputType> swift::Evaluator::getResultUncached<swift::ExecuteSILPipelineRequest>(swift::ExecuteSILPipelineRequest const&) + 241
26 swift-frontend 0x0000000106c323a2 swift::executePassPipelinePlan(swift::SILModule*, swift::SILPassPipelinePlan const&, bool, swift::irgen::IRGenModule*) + 82
27 swift-frontend 0x0000000106c401b7 swift::runSILDiagnosticPasses(swift::SILModule&) + 87
28 swift-frontend 0x00000001063f731c swift::CompilerInstance::performSILProcessing(swift::SILModule*) + 60
29 swift-frontend 0x00000001062955f1 performCompileStepsPostSILGen(swift::CompilerInstance&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*) + 625
30 swift-frontend 0x0000000106294c15 performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 693
31 swift-frontend 0x000000010628a265 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3845
32 swift-frontend 0x000000010623c0a9 swift::mainEntry(int, char const**) + 553
33 libdyld.dylib 0x00007fff2033df3d start + 1
34 libdyld.dylib 0x0000000000000047 start + 18446603339975893259
error: Abort trap: 6 (in target 'VarDeclCrasher' from project 'VarDeclCrasher')