Skip to content

Instantly share code, notes, and snippets.

@y-yu
Last active May 27, 2016 05:18
Show Gist options
  • Select an option

  • Save y-yu/f26af24ea2e073fadad6ff81fc201cb1 to your computer and use it in GitHub Desktop.

Select an option

Save y-yu/f26af24ea2e073fadad6ff81fc201cb1 to your computer and use it in GitHub Desktop.
Swift Segmentation Fault
protocol Transform1 {
associatedtype From
associatedtype To
static func apply(x: From) -> To
}
protocol Transform {
associatedtype From
associatedtype To
static func apply(x: From) -> To
}
struct Identity<A> { }
struct Transitive<A, B, C> { }
extension Identity: Transform {
typealias From = A
typealias To = A
static func apply(x: From) -> To {
return x
}
}
extension Transitive: Transform {
typealias From = A
typealias To = C
static func apply<F: Transform1, G: Transform
where F.From == From,
F.To == B,
G.From == B,
G.To == To>(x: From) -> To {
return G.apply(F.apply(x))
}
}
$ swiftc -o extensible_exception extensible_exception.swift
0 swift 0x000000010b86d66b llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 43
1 swift 0x000000010b86c956 llvm::sys::RunSignalHandlers() + 70
2 swift 0x000000010b86dccf SignalHandler(int) + 287
3 libsystem_platform.dylib 0x00007fff879e252a _sigtramp + 26
4 libsystem_platform.dylib 0x00007fff56646ec0 _sigtramp + 3469101488
5 swift 0x00000001096720ec swift::irgen::emitLazyCacheAccessFunction(swift::irgen::IRGenModule&, llvm::Function*, llvm::GlobalVariable*, llvm::function_ref<llvm::Value* (swift::irgen::IRGenFunction&)> const&) + 588
6 swift 0x00000001096731f2 getTypeMetadataAccessFunction(swift::irgen::IRGenModule&, swift::CanType, swift::ForDefinition_t) + 194
7 swift 0x000000010967303a emitCallToTypeMetadataAccessFunction(swift::irgen::IRGenFunction&, swift::CanType, swift::ForDefinition_t) + 58
8 swift 0x00000001096c02ff swift::irgen::emitPolymorphicArguments(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::SILFunctionType>, swift::CanTypeWrapper<swift::SILFunctionType>, llvm::ArrayRef<swift::Substitution>, swift::irgen::WitnessMetadata*, swift::irgen::Explosion&) + 575
9 swift 0x0000000109708a3b (anonymous namespace)::IRGenSILFunction::visitFullApplySite(swift::FullApplySite) + 2699
10 swift 0x00000001096f623b swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 9787
11 swift 0x00000001096515c8 swift::irgen::IRGenModuleDispatcher::emitGlobalTopLevel() + 600
12 swift 0x00000001096dd04e performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, swift::SILModule*, llvm::StringRef, llvm::LLVMContext&, swift::SourceFile*, unsigned int) + 1278
13 swift 0x00000001096dd4f6 swift::performIRGeneration(swift::IRGenOptions&, swift::SourceFile&, swift::SILModule*, llvm::StringRef, llvm::LLVMContext&, unsigned int) + 70
14 swift 0x00000001095c0c8c performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&) + 15004
15 swift 0x00000001095bc68d frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 2781
16 swift 0x00000001095b80ac main + 1932
17 libdyld.dylib 0x00007fff879df5ad start + 1
Stack dump:
0. Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file extensible_exception.swift -target x86_64-apple-macosx10.9 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -color-diagnostics -module-name extensible_exception -o /var/folders/d3/g_g82mtd3jx7cpbbhlsfcz9xmdx9x0/T/extensible_exception-9fc15c.o
1. While emitting IR SIL function @_TTWu1_rGV20extensible_exception10Transitivexq_q0__S_9TransformS_ZFS1_5applyfwx4Fromwx2To for 'apply' at extensible_exception.swift:32:3
<unknown>:0: error: unable to execute command: Segmentation fault: 11
<unknown>:0: error: compile command failed due to signal (use -v to see invocation)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment