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-4487] Crash when pattern matching two cases with associated values of protocol type #47064

Closed
rxwei opened this issue Apr 4, 2017 · 1 comment
Labels
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

Comments

@rxwei
Copy link
Member

rxwei commented Apr 4, 2017

Previous ID SR-4487
Radar None
Original Reporter @rxwei
Type Bug
Status Resolved
Resolution Duplicate
Environment

3.1

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash, SILGen
Assignee None
Priority Medium

md5: a545da02adca998e1913031050b3b288

duplicates:

  • SR-4439 Compiler crashes when chaining case statements that capture values with weak references

Issue Description:

Crash:

protocol Foo {
}

enum Bar {
    case aaa(Foo)
    case bbb(Foo)
}

func acceptBar(_ x: Bar) {  /// Crash here
    switch x {
    case let .aaa(f),
         let .bbb(f):
        break
    }
}

No crash if switch written as

func acceptBar(_ x: Bar) {
    switch x {
    case let .aaa(f): break
    case let .bbb(f): break
    }
}
0  swift                    0x00000001123deeb7 PrintStackTraceSignalHandler(void*) + 39
1  swift                    0x00000001123de366 SignalHandler(int) + 646
2  libsystem_platform.dylib 0x00007fff8fa31b3a _sigtramp + 26
3  libsystem_platform.dylib 0x0000000000000002 _sigtramp + 1885136098
4  swift                    0x000000010fe307be (anonymous namespace)::TypeClassifierBase<(anonymous namespace)::LowerType, swift::Lowering::TypeLowering const*>::visitExistentialType(swift::CanType) + 30
5  swift                    0x000000010fe2fadc swift::Lowering::TypeConverter::getTypeLoweringForUncachedLoweredType(swift::Lowering::TypeConverter::TypeKey) + 76
6  swift                    0x000000010fe2f318 swift::Lowering::TypeConverter::getTypeLowering(swift::Lowering::AbstractionPattern, swift::Type, unsigned int) + 2328
7  swift                    0x000000010fa52413 swift::Lowering::emitBeginVarargs(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::CanType, swift::CanType, unsigned int) + 675
8  swift                    0x000000010f9fbfc1 (anonymous namespace)::ArgEmitter::emitShuffle(swift::Expr*, swift::Expr*, llvm::ArrayRef<swift::TupleTypeElt>, swift::ConcreteDeclRef, llvm::ArrayRef<swift::Expr*>, llvm::ArrayRef<int>, llvm::ArrayRef<unsigned int>, swift::Type, swift::Lowering::AbstractionPattern) + 2145
9  swift                    0x000000010f9fa676 (anonymous namespace)::ArgEmitter::emitExpanded(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 1958
10 swift                    0x000000010f9f7bde (anonymous namespace)::ArgEmitter::emit(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 286
11 swift                    0x000000010f9f7246 (anonymous namespace)::CallSite::emit(swift::Lowering::SILGenFunction&, swift::Lowering::AbstractionPattern, (anonymous namespace)::ParamLowering&, llvm::SmallVectorImpl<swift::Lowering::ManagedValue>&, llvm::SmallVectorImpl<std::__1::pair<swift::Lowering::LValue, swift::SILLocation> >&, llvm::Optional<swift::ForeignErrorConvention> const&, swift::ImportAsMemberStatus const&) && + 438
12 swift                    0x000000010f9f459b (anonymous namespace)::CallEmission::apply(swift::Lowering::SGFContext) + 6123
13 swift                    0x000000010fa402ec swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 124
14 swift                    0x000000010fa9db73 swift::Lowering::SILGenFunction::emitReturnExpr(swift::SILLocation, swift::Expr*) + 467
15 swift                    0x000000010fa99acc swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 188
16 swift                    0x000000010fa9d268 swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 14424
17 swift                    0x000000010fa798ca void llvm::function_ref<void ((anonymous namespace)::PatternMatchEmission&, llvm::ArrayRef<swift::Lowering::ConsumableManagedValue>, (anonymous namespace)::ClauseRow&)>::callback_fn<swift::Lowering::SILGenFunction::emitSwitchStmt(swift::SwitchStmt*)::$_1>(long, (anonymous namespace)::PatternMatchEmission&, llvm::ArrayRef<swift::Lowering::ConsumableManagedValue>, (anonymous namespace)::ClauseRow&) + 458
18 swift                    0x000000010fa7b040 (anonymous namespace)::PatternMatchEmission::emitDispatch((anonymous namespace)::ClauseMatrix&, llvm::ArrayRef<swift::Lowering::ConsumableManagedValue>, std::__1::function<void (swift::SILLocation)> const&) + 4448
19 swift                    0x000000010fa82973 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&) + 3219
20 swift                    0x000000010fa7e9e0 (anonymous namespace)::PatternMatchEmission::emitDispatch((anonymous namespace)::ClauseMatrix&, llvm::ArrayRef<swift::Lowering::ConsumableManagedValue>, std::__1::function<void (swift::SILLocation)> const&) + 19200
21 swift                    0x000000010fa82973 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&) + 3219
22 swift                    0x000000010fa7d294 (anonymous namespace)::PatternMatchEmission::emitDispatch((anonymous namespace)::ClauseMatrix&, llvm::ArrayRef<swift::Lowering::ConsumableManagedValue>, std::__1::function<void (swift::SILLocation)> const&) + 13236
23 swift                    0x000000010fa790a3 swift::Lowering::SILGenFunction::emitSwitchStmt(swift::SwitchStmt*) + 2419
24 swift                    0x000000010fa9d268 swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 14424
25 swift                    0x000000010fa5c979 swift::Lowering::SILGenFunction::emitFunction(swift::FuncDecl*) + 409
26 swift                    0x000000010f9ddd2b swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*)::$_1::operator()(swift::SILFunction*) const + 1867
27 swift                    0x000000010f9dc902 swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) + 642
28 swift                    0x000000010faa357a swift::Lowering::SILGenModule::visitExtensionDecl(swift::ExtensionDecl*) + 634
29 swift                    0x000000010f9ea33b swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*, unsigned int) + 1483
30 swift                    0x000000010f9ebf19 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*, llvm::Optional<unsigned int>, bool, bool) + 1593
31 swift                    0x000000010f1fe0b2 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 42402
32 swift                    0x000000010f1ad88c main + 9052
33 libdyld.dylib            0x00007fff8f822235 start + 1
@rxwei
Copy link
Member Author

rxwei commented Apr 4, 2017

Duped

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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
Projects
None yet
Development

No branches or pull requests

2 participants