Swift 2b5: swiftc crash in malformed program unifying function with enum
| Originator: | rix.rob | ||
| Number: | rdar://22202790 | Date Originated: | 08-Aug-2015 01:13 PM |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Xcode-beta (7A176x) |
| Classification: | Crash/Hang/Data Loss | Reproducible: | Always |
Summary:
Another case where an untypable program crashes swiftc.
Steps to Reproduce:
1. This ill-formed program:
enum E<R> {
case U
static func f(t: R, _ f: R -> R) -> E {
return .U
}
}
enum D {
case C
case A(() -> E<D>, E<D> -> D)
var v: E<D> {
switch self {
case .C:
return .U
case let .A(x, c):
return E.f(x) { a in c(a.v) }
}
}
}
Expected Results:
should not crash swiftc
Actual Results:
but totally does:
rob@Resonance ~/Desktop> swiftc boom.swift; and ./boom
UnresolvedDotExpr should not survive to SILGen
UNREACHABLE executed at /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-700.0.52.2/src/swift/include/swift/AST/ExprNodes.def:78!
0 swift 0x000000010f1abbbb llvm::sys::PrintStackTrace(__sFILE*) + 43
1 swift 0x000000010f1ac2fb SignalHandler(int) + 379
2 libsystem_platform.dylib 0x00007fff9644deaa _sigtramp + 26
3 swift 0x000000010f791ab7 FirstTarget + 63567
4 swift 0x000000010f1ac0f6 abort + 22
5 swift 0x000000010f165931 llvm::llvm_unreachable_internal(char const*, char const*, unsigned int) + 481
6 swift 0x000000010d3912bd swift::ASTVisitor<(anonymous namespace)::SILGenApply, void, void, void, void, void, void>::visit(swift::Expr*) + 6061
7 swift 0x000000010d39562c (anonymous namespace)::SILGenApply::visitApplyExpr(swift::ApplyExpr*) + 4668
8 swift 0x000000010d38618f prepareApplyExpr(swift::Lowering::SILGenFunction&, swift::Expr*) + 175
9 swift 0x000000010d38609f swift::Lowering::SILGenFunction::emitApplyExpr(swift::Expr*, swift::Lowering::SGFContext) + 47
10 swift 0x000000010d3c6e67 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 87
11 swift 0x000000010d3c0723 swift::Lowering::SILGenFunction::emitRValue(swift::Expr*, swift::Lowering::SGFContext) + 35
12 swift 0x000000010d416a7a swift::Lowering::SILGenFunction::emitReturnExpr(swift::SILLocation, swift::Expr*) + 362
13 swift 0x000000010d413c73 swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 707
14 swift 0x000000010d413b61 swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 433
15 swift 0x000000010d4139a5 swift::Lowering::SILGenFunction::emitStmt(swift::Stmt*) + 21
16 swift 0x000000010d3fe792 void llvm::function_ref<void ((anonymous namespace)::PatternMatchEmission&, (anonymous namespace)::ClauseRow&)>::callback_fn<swift::Lowering::SILGenFunction::emitSwitchStmt(swift::SwitchStmt*)::$_0>(long, (anonymous namespace)::PatternMatchEmission&, (anonymous namespace)::ClauseRow&) + 226
17 swift 0x000000010d3f5bae (anonymous namespace)::PatternMatchEmission::emitDispatch((anonymous namespace)::ClauseMatrix&, llvm::ArrayRef<swift::Lowering::ConsumableManagedValue>, std::__1::function<void (swift::SILLocation)> const&) + 2238
18 swift 0x000000010d3fd199 std::__1::__function::__func<(anonymous namespace)::PatternMatchEmission::emitSpecializedDispatch((anonymous namespace)::ClauseMatrix&, llvm::ArrayRef<swift::Lowering::ConsumableManagedValue>, unsigned int&, unsigned int, std::__1::function<void (swift::SILLocation)> const&)::$_7, std::__1::allocator<(anonymous namespace)::PatternMatchEmission::emitSpecializedDispatch((anonymous namespace)::ClauseMatrix&, llvm::ArrayRef<swift::Lowering::ConsumableManagedValue>, unsigned int&, unsigned int, std::__1::function<void (swift::SILLocation)> const&)::$_7>, void (llvm::ArrayRef<swift::Lowering::ConsumableManagedValue>, llvm::ArrayRef<(anonymous namespace)::SpecializedRow>, std::__1::function<void (swift::SILLocation)> const&)>::operator()(llvm::ArrayRef<swift::Lowering::ConsumableManagedValue>&&, llvm::ArrayRef<(anonymous namespace)::SpecializedRow>&&, std::__1::function<void (swift::SILLocation)> const&) + 1929
19 swift 0x000000010d3f961c (anonymous namespace)::PatternMatchEmission::emitSpecializedDispatch((anonymous namespace)::ClauseMatrix&, llvm::ArrayRef<swift::Lowering::ConsumableManagedValue>, unsigned int&, unsigned int, std::__1::function<void (swift::SILLocation)> const&) + 8476
20 swift 0x000000010d3f56f1 (anonymous namespace)::PatternMatchEmission::emitDispatch((anonymous namespace)::ClauseMatrix&, llvm::ArrayRef<swift::Lowering::ConsumableManagedValue>, std::__1::function<void (swift::SILLocation)> const&) + 1025
21 swift 0x000000010d3fd199 std::__1::__function::__func<(anonymous namespace)::PatternMatchEmission::emitSpecializedDispatch((anonymous namespace)::ClauseMatrix&, llvm::ArrayRef<swift::Lowering::ConsumableManagedValue>, unsigned int&, unsigned int, std::__1::function<void (swift::SILLocation)> const&)::$_7, std::__1::allocator<(anonymous namespace)::PatternMatchEmission::emitSpecializedDispatch((anonymous namespace)::ClauseMatrix&, llvm::ArrayRef<swift::Lowering::ConsumableManagedValue>, unsigned int&, unsigned int, std::__1::function<void (swift::SILLocation)> const&)::$_7>, void (llvm::ArrayRef<swift::Lowering::ConsumableManagedValue>, llvm::ArrayRef<(anonymous namespace)::SpecializedRow>, std::__1::function<void (swift::SILLocation)> const&)>::operator()(llvm::ArrayRef<swift::Lowering::ConsumableManagedValue>&&, llvm::ArrayRef<(anonymous namespace)::SpecializedRow>&&, std::__1::function<void (swift::SILLocation)> const&) + 1929
22 swift 0x000000010d3fabb1 (anonymous namespace)::PatternMatchEmission::emitSpecializedDispatch((anonymous namespace)::ClauseMatrix&, llvm::ArrayRef<swift::Lowering::ConsumableManagedValue>, unsigned int&, unsigned int, std::__1::function<void (swift::SILLocation)> const&) + 14001
23 swift 0x000000010d3f56f1 (anonymous namespace)::PatternMatchEmission::emitDispatch((anonymous namespace)::ClauseMatrix&, llvm::ArrayRef<swift::Lowering::ConsumableManagedValue>, std::__1::function<void (swift::SILLocation)> const&) + 1025
24 swift 0x000000010d3f4db8 swift::Lowering::SILGenFunction::emitSwitchStmt(swift::SwitchStmt*) + 2216
25 swift 0x000000010d413b61 swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 433
26 swift 0x000000010d4139a5 swift::Lowering::SILGenFunction::emitStmt(swift::Stmt*) + 21
27 swift 0x000000010d3dada6 swift::Lowering::SILGenFunction::emitFunction(swift::FuncDecl*) + 390
28 swift 0x000000010d378601 swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) + 513
29 swift 0x000000010d41987c (anonymous namespace)::SILGenType::emitType() + 1132
30 swift 0x000000010d41936e swift::Lowering::SILGenModule::visitNominalTypeDecl(swift::NominalTypeDecl*) + 30
31 swift 0x000000010d37c60b swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*, unsigned int) + 587
32 swift 0x000000010d37d4af swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*, llvm::Optional<unsigned int>, bool, bool) + 991
33 swift 0x000000010d37d90b swift::performSILGeneration(swift::FileUnit&, swift::SILOptions&, llvm::Optional<unsigned int>, bool) + 123
34 swift 0x000000010d16f36e performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&) + 12622
35 swift 0x000000010d16bfc8 frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 2728
36 swift 0x000000010d16802f main + 2015
37 libdyld.dylib 0x00007fff94b775ad start + 1
Stack dump:
0. Program arguments: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file boom.swift -target x86_64-apple-darwin15.0.0 -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -color-diagnostics -module-name boom -o /var/folders/9y/f7n4rvx901nctm_5d16c1wm40000gn/T/boom-d296d8.o
1. While emitting SIL for getter for v at boom.swift:13:14
<unknown>:0: error: unable to execute command: Illegal instruction: 4
<unknown>:0: error: swift frontend command failed due to signal (use -v to see invocation)
Regression:
It doesn’t crash if you add a `return .U` before the switch.
Notes:
N/A
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!