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-11561] Letting SwiftUI Binding conditionally conform to Sequence and Collection crashes compiler #53966

Closed
swift-ci opened this issue Oct 2, 2019 · 3 comments
Assignees
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 2, 2019

Previous ID SR-11561
Radar rdar://problem/55987394
Original Reporter palle (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate
Environment

Apple Swift version 5.1 (swiftlang-1100.0.270.13 clang-1100.0.33.7).

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash
Assignee @theblixguy
Priority Medium

md5: 20e489842f3ab19e79463ebc62434f4d

duplicates:

  • SR-11521 Compiler crash - segfault when trying to make an extension on Result type

Issue Description:

The following code crashes the compiler (and REPL):

import Foundation
import SwiftUI

extension Binding: Sequence where Value: MutableCollection {
    public typealias Iterator = AnyIterator<Binding<Value.Element>>
    public typealias Element = Binding<Value.Element>
    
    public __consuming func makeIterator() -> AnyIterator<Binding<Value.Element>> {
        fatalError()
    }
}


extension Binding: Collection where Value: (MutableCollection & RandomAccessCollection) {
    public var startIndex: Value.Index {
        wrappedValue.startIndex
    }
    
    public var endIndex: Value.Index {
        wrappedValue.endIndex
    }
    
    public subscript(position: Value.Index) -> Binding<Value.Element> {
        fatalError()
    }
    
    public func index(after i: Value.Index) -> Value.Index {
        wrappedValue.index(after: i)
    }
}

Stack Trace:

1.  While emitting witness table for protocol conformance to 'Collection' (in module 'Swift') for type 'Binding<Value>'
0  swift                    0x0000000109d9eeb3 PrintStackTraceSignalHandler(void*) + 51
1  swift                    0x0000000109d9e686 SignalHandler(int) + 358
2  libsystem_platform.dylib 0x00007fff64b9bb1d _sigtramp + 29
3  libsystem_platform.dylib 0x0000000000000060 _sigtramp + 2605073760
4  swift                    0x000000010692258f swift::GenericSignature::getConformanceAccessPath(swift::Type, swift::ProtocolDecl*) + 31
5  swift                    0x000000010687d768 swift::Mangle::ASTMangler::appendConcreteProtocolConformance(swift::ProtocolConformance const*) + 1784
6  swift                    0x000000010687a893 swift::Mangle::ASTMangler::appendRetroactiveConformances(swift::SubstitutionMap, swift::ModuleDecl*) + 179
7  swift                    0x0000000106879e05 swift::Mangle::ASTMangler::appendRetroactiveConformances(swift::Type) + 389
8  swift                    0x0000000106878cb0 swift::Mangle::ASTMangler::appendType(swift::Type, swift::ValueDecl const*) + 8864
9  swift                    0x0000000105c1eb2f swift::irgen::IRGenMangler::mangleTypeForReflection(swift::irgen::IRGenModule&, swift::Type) + 255
10 swift                    0x0000000105bc635b swift::irgen::IRGenModule::getTypeRef(swift::CanType, swift::irgen::MangledTypeRefRole) + 587
11 swift                    0x0000000105bbcce0 swift::irgen::IRGenModule::emitSILWitnessTable(swift::SILWitnessTable*) + 2304
12 swift                    0x0000000105ad99e8 swift::irgen::IRGenerator::emitGlobalTopLevel() + 1976
13 swift                    0x0000000105c0a065 performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::LLVMContext&, swift::SourceFile*, llvm::GlobalVariable**) + 1189
14 swift                    0x00000001059f678a performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 36682
15 swift                    0x00000001059ea034 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 6820
16 swift                    0x00000001059775a3 main + 1219
17 libdyld.dylib            0x00007fff649962a5 start + 1
@belkadan
Copy link
Contributor

belkadan commented Oct 2, 2019

It's not really a great idea to add conformances to types you don't own, but the compiler still shouldn't crash. Thanks for filing!

@swift-ci create

@theblixguy
Copy link
Collaborator

Stack trace looks like the one in SR-11521

@theblixguy
Copy link
Collaborator

Fixed on master. Please verify using the next available snapshot!

@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

4 participants