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-4417] Compiler crashes when get value from enum specific case. #46994

Open
swift-ci opened this issue Mar 29, 2017 · 4 comments
Open

[SR-4417] Compiler crashes when get value from enum specific case. #46994

swift-ci opened this issue Mar 29, 2017 · 4 comments
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 run-time crash Bug → crash: Swift code crashed during execution

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-4417
Radar None
Original Reporter tarunon (JIRA User)
Type Bug
Environment

Swift 3.1, Xcode 8.3, Playground

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

md5: f96eedb557b7078d00aa8ca0ee2987ef

relates to:

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

Issue Description:

1. Make a `enum` that have some case contain associated value.
2. Get associated value using `switch` via type casting to `protocol` (or associated value defined `protocol`).
3. Add other pattern into same case.

Minimum code is here.

protocol X {}
extension String: X {}

enum A {
    case hoge(X)
    case fuga(X)
}

let a = A.hoge("hello")

switch a {
case .hoge(let x), .fuga(let x):
    print(x)
default:
    break
}
@belkadan
Copy link
Contributor

Backtrace on master:

Assertion failed: (!v->getType().isAddress()), function emitCopyValueOperation, file /Volumes/Data/swift-public/swift/include/swift/SIL/SILBuilder.h, line 1684.
0  swift                    0x00000001102fd108 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  swift                    0x00000001102fc326 llvm::sys::RunSignalHandlers() + 86
2  swift                    0x00000001102fd759 SignalHandler(int) + 361
3  libsystem_platform.dylib 0x00007fff92992b3a _sigtramp + 26
4  libsystem_platform.dylib 000000000000000000 _sigtramp + 1835455712
5  libsystem_c.dylib        0x00007fff92817420 abort + 129
6  libsystem_c.dylib        0x00007fff927de893 basename_r + 0
7  swift                    0x000000010d9501ea 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&) + 1466
8  swift                    0x000000010d945fc2 (anonymous namespace)::PatternMatchEmission::emitDispatch((anonymous namespace)::ClauseMatrix&, llvm::ArrayRef<swift::Lowering::ConsumableManagedValue>, std::__1::function<void (swift::SILLocation)> const&) + 3122
9  swift                    0x000000010d94d216 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&) + 1926
10 swift                    0x000000010d94a176 (anonymous namespace)::PatternMatchEmission::emitSpecializedDispatch((anonymous namespace)::ClauseMatrix&, llvm::ArrayRef<swift::Lowering::ConsumableManagedValue>, unsigned int&, unsigned int, std::__1::function<void (swift::SILLocation)> const&) + 9462
11 swift                    0x000000010d94593a (anonymous namespace)::PatternMatchEmission::emitDispatch((anonymous namespace)::ClauseMatrix&, llvm::ArrayRef<swift::Lowering::ConsumableManagedValue>, std::__1::function<void (swift::SILLocation)> const&) + 1450
12 swift                    0x000000010d944c65 swift::Lowering::SILGenFunction::emitSwitchStmt(swift::SwitchStmt*) + 2117
13 swift                    0x000000010d96a295 swift::Lowering::SILGenFunction::emitStmt(swift::Stmt*) + 21

@gottesmm, you were going to attack pattern-matching soon anyway, right?

@belkadan
Copy link
Contributor

(without assertions we get through compilation but then crash at run time)

@gottesmm
Copy link
Member

@belkadan In the next little bit. I have patches on master that are behind a flag.

@gottesmm
Copy link
Member

I am fixing 1 thing before I get back to it.

@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 Oct 22, 2022
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 run-time crash Bug → crash: Swift code crashed during execution
Projects
None yet
Development

No branches or pull requests

4 participants