-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed
Closed
Copy link
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of software
Description
| Previous ID | SR-6058 |
| Radar | None |
| Original Reporter | tomquist (JIRA User) |
| Type | Bug |
| Status | Resolved |
| Resolution | Duplicate |
Environment
Apple Swift version 4.0 (swiftlang-900.0.65 clang-900.0.37)
Target: x86_64-apple-macosx10.9
Xcode Version 9.0 (9A235)
Additional Detail from JIRA
| Votes | 0 |
| Component/s | Compiler |
| Labels | Bug, CompilerCrash |
| Assignee | None |
| Priority | Medium |
md5: 1f226bf839c4e916bae920219e962a09
duplicates:
- SR-5932 Segmentation fault: 11 when creating a Set of optionals
Issue Description:
The following code crashes the compiler:
struct SetWrapper<T: Hashable> {
let items: Set<T>
init<S: Sequence>(events: S) where S.Iterator.Element == T {
self.items = Set(events)
}
}
extension SetWrapper: Collection, ExpressibleByArrayLiteral {
typealias Index = Set<Element>.Index
typealias Element = T
init(arrayLiteral elements: Element...) {
self = SetWrapper(events: elements)
}
var startIndex: Index {
return items.startIndex
}
var endIndex: Index {
return items.endIndex
}
func index(after index: Index) -> Index {
return items.index(after: index)
}
subscript(index: Index) -> Element {
return items[index]
}
func flatMap<O: Hashable>(_ transform: (Element) throws -> O?) rethrows -> SetWrapper<O> {
return try SetWrapper(events: lazy.flatMap(transform))
}
}This is the error message and stacktrace:
0 swift 0x0000000104b98dba PrintStackTraceSignalHandler(void*) + 42
1 swift 0x0000000104b981f6 SignalHandler(int) + 662
2 libsystem_platform.dylib 0x00007fffb8b70b3a _sigtramp + 26
3 libsystem_platform.dylib 000000000000000000 _sigtramp + 1195963616
4 swift 0x00000001026f6c15 swift::NominalTypeDecl::hasFixedLayout() const + 21
5 swift 0x000000010228a931 (anonymous namespace)::LowerType::visitAnyStructType(swift::CanType, swift::StructDecl*) + 49
6 swift 0x00000001022896c7 swift::Lowering::TypeConverter::getTypeLowering(swift::Lowering::AbstractionPattern, swift::Type) + 2791
7 swift 0x0000000101d58df4 swift::Lowering::ResultPlanBuilder::build(swift::Lowering::Initialization*, swift::Lowering::AbstractionPattern, swift::CanType) + 692
8 swift 0x0000000101d5ac4a swift::Lowering::ResultPlanBuilder::computeResultPlan(swift::Lowering::SILGenFunction&, swift::Lowering::CalleeTypeInfo const&, swift::SILLocation, swift::Lowering::SGFContext) + 826
9 swift 0x0000000101d78c55 (anonymous namespace)::CallEmission::apply(swift::Lowering::SGFContext) + 1509
10 swift 0x0000000101dd0909 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 105
11 swift 0x0000000101e43394 swift::Lowering::SILGenFunction::emitReturnExpr(swift::SILLocation, swift::Expr*) + 740
12 swift 0x0000000101e3da7a swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 202
13 swift 0x0000000101e3e007 swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 1623
14 swift 0x0000000101df5389 swift::Lowering::SILGenFunction::emitFunction(swift::FuncDecl*) + 393
15 swift 0x0000000101d6b3a1 swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*)::$_1::operator()(swift::SILFunction*) const + 273
16 swift 0x0000000101d6a919 swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) + 761
17 swift 0x0000000101e4d4c6 swift::Lowering::SILGenModule::visitExtensionDecl(swift::ExtensionDecl*) + 422
18 swift 0x0000000101d70f6b swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*, unsigned int) + 1115
19 swift 0x0000000101d728f9 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*, llvm::Optional<unsigned int>, bool) + 841
20 swift 0x000000010150b2c6 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 13014
21 swift 0x0000000101506784 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7716
22 swift 0x00000001014bb6a8 main + 12248
23 libdyld.dylib 0x00007fffb8961235 start + 1
Stack dump:
0. Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file test.swift -target x86_64-apple-macosx10.9 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -color-diagnostics -module-name test -o /var/folders/sg/7mgms6wn1zs529t4gqfljmh40000gp/T/test-70c920.o
1. While emitting SIL for 'flatMap(_:)' at test.swift:26:5
<unknown>:0: error: unable to execute command: Segmentation fault: 11
<unknown>:0: error: compile command failed due to signal 11 (use -v to see invocation)Metadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of software