Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Swift 2.1.1 print to stderr crashes
$ swift --version
Apple Swift version 2.1.1 (swiftlang-700.1.101.15 clang-700.1.81)
Target: x86_64-apple-darwin14.5.0
$ cat stderr.swift
import Darwin
public struct StderrStream : OutputStreamType {
public func write(string : String) {
fputs(string, stderr)
}
}
var myErrStream = StderrStream()
print("TESTING", &myErrStream)
$ swift stderr.swift
0 swift 0x000000010291cfbb llvm::sys::PrintStackTrace(__sFILE*) + 43
1 swift 0x000000010291d6fb SignalHandler(int) + 379
2 libsystem_platform.dylib 0x00007fff892eef1a _sigtramp + 26
3 libsystem_platform.dylib 0x00007fff00000004 _sigtramp + 1993412868
4 swift 0x0000000100aba0c9 emitNominalMetadataRef(swift::irgen::IRGenFunction&, swift::NominalTypeDecl*, swift::CanType) + 473
5 swift 0x0000000100ab384d getTypeMetadataAccessFunction(swift::irgen::IRGenModule&, swift::CanType, swift::ForDefinition_t) + 909
6 swift 0x0000000100aadaa9 emitCallToTypeMetadataAccessFunction(swift::irgen::IRGenFunction&, swift::CanType, swift::ForDefinition_t) + 73
7 swift 0x0000000100aeb32a swift::irgen::emitOpaqueExistentialContainerInit(swift::irgen::IRGenFunction&, swift::irgen::Address, swift::SILType, swift::CanType, swift::SILType, llvm::ArrayRef<swift::ProtocolConformance*>) + 90
8 swift 0x0000000100b31977 swift::SILVisitor<(anonymous namespace)::IRGenSILFunction, void>::visit(swift::ValueBase*) + 23159
9 swift 0x0000000100b289ad swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 10973
10 swift 0x0000000100a8eb58 swift::irgen::IRGenModuleDispatcher::emitGlobalTopLevel() + 376
11 swift 0x0000000100b0f3a4 performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, swift::SILModule*, llvm::StringRef, llvm::LLVMContext&, swift::SourceFile*, unsigned int) + 788
12 swift 0x0000000100b0e3a6 swift::performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, swift::SILModule*, llvm::StringRef, llvm::LLVMContext&) + 598
13 swift 0x0000000100d1f59a swift::RunImmediately(swift::CompilerInstance&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, swift::IRGenOptions&, swift::SILOptions const&) + 154
14 swift 0x0000000100a0e151 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&) + 13425
15 swift 0x0000000100a0aad3 frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 2691
16 swift 0x0000000100a07154 main + 2324
17 libdyld.dylib 0x00007fff96b485c9 start + 1
Stack dump:
0. Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -interpret stderr.swift -target x86_64-apple-darwin14.5.0 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -color-diagnostics -module-name stderr
1. While emitting IR SIL function @mainSegmentation fault: 11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment