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-2092] Crash When Evaluating Generic Method #44700

Open
swift-ci opened this issue Jul 15, 2016 · 2 comments
Open

[SR-2092] Crash When Evaluating Generic Method #44700

swift-ci opened this issue Jul 15, 2016 · 2 comments
Assignees
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 IRGen LLVM IR generation

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-2092
Radar None
Original Reporter BMc68 (JIRA User)
Type Bug
Environment

El Capitan 10.11.4 (15E65)
XCode Version 7.3 (7D175)

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash, IRGen
Assignee @slavapestov
Priority Medium

md5: 059bcc1857690eab8b5bde09f5f91bda

Issue Description:

I was writing some Swift extensions on Typhoon to genericise getting items out of a Typhoon Factory, and the compiler crashed while attempting to compile the following code.

Code

import Foundation
import Typhoon

extension Factory {

    func getComponent<T: Any>(_: T.Type) -> T {
        if let type = T.self as? AnyClass,
            let component = self.getComponentForClass(type) as? T {
            return component
        } else if let type: Protocol = (T.self as! Protocol),
            let componenet = self.getComponentForProtocol(type) as? T {
            return componenet
        }
        fatalError()
    }
}

Stack Trace

0  swift                    0x0000000103c554eb llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 43
1  swift                    0x0000000103c547d6 llvm::sys::RunSignalHandlers() + 70
2  swift                    0x0000000103c55b4f SignalHandler(int) + 287
3  libsystem_platform.dylib 0x00007fff8ec8452a _sigtramp + 26
4  libsystem_platform.dylib 0x00007fa4cbc73d70 _sigtramp + 1023342688
5  swift                    0x0000000101a71476 swift::irgen::IRGenFunction::emitObjCRetainCall(llvm::Value*) + 70
6  swift                    0x0000000101ae7dbd swift::SILVisitor<(anonymous namespace)::IRGenSILFunction, void>::visit(swift::ValueBase*) + 18685
7  swift                    0x0000000101adfc4b swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 9787
8  swift                    0x0000000101a3afd8 swift::irgen::IRGenModuleDispatcher::emitGlobalTopLevel() + 600
9  swift                    0x0000000101ac6a5e performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, swift::SILModule*, llvm::StringRef, llvm::LLVMContext&, swift::SourceFile*, unsigned int) + 1278
10 swift                    0x0000000101ac6f06 swift::performIRGeneration(swift::IRGenOptions&, swift::SourceFile&, swift::SILModule*, llvm::StringRef, llvm::LLVMContext&, unsigned int) + 70
11 swift                    0x00000001019aaa1c performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&) + 15004
12 swift                    0x00000001019a641d frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 2781
13 swift                    0x00000001019a1e3c main + 1932
14 libdyld.dylib            0x00007fff999d75ad start + 1

[REDACTED]

1.  While emitting IR SIL function @_TFE22*[REDACTED]*CSo7Factory12getComponenturfMxx for 'getComponent' at *[REDACTED]*/Factory+Swift.swift:14:5
@belkadan
Copy link
Contributor

@belkadan
Copy link
Contributor

Your code has as! rather than as?, which makes me think it's incorrect anyway, but that doesn't mean the compiler should crash.

@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
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 IRGen LLVM IR generation
Projects
None yet
Development

No branches or pull requests

3 participants