Skip to content

[SR-4812] swiftc crash in swift::Lowering::SILGenFunction::emitClosureValue #47389

@weissi

Description

@weissi
Previous ID SR-4812
Radar rdar://problem/40600800
Original Reporter @weissi
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash
Assignee @slavapestov
Priority Medium

md5: 989a26d4b61afd91741e0078af477b2b

is duplicated by:

  • SR-9015 Code completion assertion failure: (D->hasValidSignature()), function getType, file swift/lib/Sema/ConstraintSystem.h
  • SR-10687 Swift compiler crash in swift::Lowering::SILGenFunction::emitClosureValue with calling higher function, variable, inner function

Issue Description:

For this non-sensical program

class X {
    public func foo() {
        let bar = { [weak self] in
            bar2()
        }
        func bar2() {
            bar()
        }
        bar()
    }
}

let x = X()
x.foo()

I get

0  swift                    0x00000001057544f7 PrintStackTraceSignalHandler(void*) + 39
1  swift                    0x00000001057539a6 SignalHandler(int) + 646
2  libsystem_platform.dylib 0x00007fffb48d7b3a _sigtramp + 26
3  libsystem_platform.dylib 0x000000000000000e _sigtramp + 1265796334
4  swift                    0x0000000102dd1bd3 swift::Lowering::SILGenFunction::emitClosureValue(swift::SILLocation, swift::SILDeclRef, swift::CanType, llvm::ArrayRef<swift::Substitution>) + 771
5  swift                    0x0000000102dc6112 (anonymous namespace)::RValueEmitter::visitAbstractClosureExpr(swift::AbstractClosureExpr*, swift::Lowering::SGFContext) + 194
6  swift                    0x0000000102dbb7d9 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 23001
7  swift                    0x0000000102db5c9c swift::Lowering::SILGenFunction::emitExprInto(swift::Expr*, swift::Lowering::Initialization*) + 188
8  swift                    0x0000000102da36e6 swift::Lowering::SILGenFunction::emitPatternBinding(swift::PatternBindingDecl*, unsigned int) + 198
9  swift                    0x0000000102e12ee8 swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 14712
10 swift                    0x0000000102dd2509 swift::Lowering::SILGenFunction::emitFunction(swift::FuncDecl*) + 409
11 swift                    0x0000000102d5389b swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*)::$_1::operator()(swift::SILFunction*) const + 1867
12 swift                    0x0000000102d528a2 swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) + 642
13 swift                    0x0000000102e17efb (anonymous namespace)::SILGenType::emitType() + 971
14 swift                    0x0000000102e17acd swift::Lowering::SILGenModule::visitNominalTypeDecl(swift::NominalTypeDecl*) + 29
15 swift                    0x0000000102d5fecb swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*, unsigned int) + 1483
16 swift                    0x0000000102d61aa9 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*, llvm::Optional<unsigned int>, bool, bool) + 1593
17 swift                    0x0000000102572604 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 42516
18 swift                    0x0000000102521d6c main + 9052
19 libdyld.dylib            0x00007fffb46c8235 start + 1
20 libdyld.dylib            0x000000000000000f start + 1267957211

and

$ swift -version
Apple Swift version 3.1 (swiftlang-802.0.53 clang-802.0.42)
Target: x86_64-apple-macosx10.9

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of software

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions