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-6058] Segmentation fault: 11 when emitting SIL for custom collection function #48615

Closed
swift-ci opened this issue Oct 4, 2017 · 0 comments
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

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Oct 4, 2017

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)
@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
This issue was closed.
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
Projects
None yet
Development

No branches or pull requests

2 participants