Last active
January 2, 2017 22:20
-
-
Save mgadda/c0f4c0448237a22bf99083b704e8faf4 to your computer and use it in GitHub Desktop.
A simple but likely not fully distilled code snippet which produces swiftc segfault
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| > swiftc main.swift | |
| 0 swift 0x00000001094d13ad PrintStackTraceSignalHandler(void*) + 45 | |
| 1 swift 0x00000001094d0b56 SignalHandler(int) + 790 | |
| 2 libsystem_platform.dylib 0x00007fffa03fcbba _sigtramp + 26 | |
| 3 libsystem_platform.dylib 0x00007fdef523a8a8 _sigtramp + 1424219400 | |
| 4 swift 0x00000001066b979c swift::ASTVisitor<(anonymous namespace)::SILGenApply, void, void, void, void, void, void>::visit(swift::Expr*) + 4492 | |
| 5 swift 0x00000001066be19e (anonymous namespace)::SILGenApply::visitApplyExpr(swift::ApplyExpr*) + 5166 | |
| 6 swift 0x00000001066ac5f1 prepareApplyExpr(swift::Lowering::SILGenFunction&, swift::Expr*) + 273 | |
| 7 swift 0x00000001066fd8b7 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 103 | |
| 8 swift 0x000000010675dfaa swift::Lowering::SILGenFunction::emitReturnExpr(swift::SILLocation, swift::Expr*) + 506 | |
| 9 swift 0x000000010675a7d7 swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 183 | |
| 10 swift 0x000000010675b6d6 swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 4022 | |
| 11 swift 0x000000010671bfa8 swift::Lowering::SILGenFunction::emitClosure(swift::AbstractClosureExpr*) + 312 | |
| 12 swift 0x000000010669ce31 swift::Lowering::SILGenModule::emitClosure(swift::AbstractClosureExpr*) + 1089 | |
| 13 swift 0x000000010670eb59 (anonymous namespace)::RValueEmitter::visitAbstractClosureExpr(swift::AbstractClosureExpr*, swift::Lowering::SGFContext) + 41 | |
| 14 swift 0x00000001066888a4 swift::Lowering::ArgumentSource::getAsSingleValue(swift::Lowering::SILGenFunction&, swift::Lowering::SGFContext) && + 388 | |
| 15 swift 0x00000001066b2532 (anonymous namespace)::ArgEmitter::emit(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 2050 | |
| 16 swift 0x00000001066b6d1d (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) + 3885 | |
| 17 swift 0x00000001066b4ca3 (anonymous namespace)::ArgEmitter::emitExpanded(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 2131 | |
| 18 swift 0x00000001066b1e29 (anonymous namespace)::ArgEmitter::emit(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 249 | |
| 19 swift 0x00000001066b1407 (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&) && + 519 | |
| 20 swift 0x00000001066ae09b (anonymous namespace)::CallEmission::apply(swift::Lowering::SGFContext) + 5339 | |
| 21 swift 0x00000001066fd8c5 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 117 | |
| 22 swift 0x0000000106711b40 swift::Lowering::SILGenFunction::emitIgnoredExpr(swift::Expr*) + 592 | |
| 23 swift 0x00000001066a3aa2 swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*, unsigned int) + 2098 | |
| 24 swift 0x00000001066a562d swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*, llvm::Optional<unsigned int>, bool, bool) + 1629 | |
| 25 swift 0x00000001064dde86 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*) + 19510 | |
| 26 swift 0x00000001064d72b3 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 17859 | |
| 27 swift 0x00000001064935cf main + 8239 | |
| 28 libdyld.dylib 0x00007fffa01ef255 start + 1 | |
| 29 libdyld.dylib 0x000000000000000f start + 1608584635 | |
| Stack dump: | |
| 0. Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file main.swift -target x86_64-apple-macosx10.9 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -color-diagnostics -module-name main -o /var/folders/xd/p1bhx8rj4yd3lc456ct5kw500000gn/T/main-c46fdb.o | |
| 1. While silgen closureexpr SIL function @_TF4mainU_FP_T_ for expression at [main.swift:24:13 - line:26:1] RangeText="{ results in | |
| processResults(results) | |
| }" | |
| <unknown>:0: error: unable to execute command: Segmentation fault: 11 | |
| <unknown>:0: error: compile command failed due to signal (use -v to see invocation) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // To reproduce, run: | |
| // git clone https://gist.github.com/c0f4c0448237a22bf99083b704e8faf4.git segfault | |
| // cd segfault | |
| // swiftc swiftc_segfault.swift | |
| func makeInt() -> Int? { | |
| return .none | |
| } | |
| guard let myInt = makeInt() else { | |
| fatalError("we've run out of integers") | |
| } | |
| func bar() { | |
| myInt | |
| } | |
| func foo(f: () -> ()) {} | |
| foo { bar() } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment