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-6778] Minimal Collection conformance causes segmentation fault 11 #49327

Open
swift-ci opened this issue Jan 17, 2018 · 3 comments
Open

[SR-6778] Minimal Collection conformance causes segmentation fault 11 #49327

swift-ci opened this issue Jan 17, 2018 · 3 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-6778
Radar rdar://problem/36587279
Original Reporter wll (JIRA User)
Type Bug

Attachment: Download

Environment

Swift 4.0.3, macOS 10.13.2.

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

md5: 02486b76b504fb15e1e166ba0ae0c52d

Issue Description:

protocol Graph: Collection {
    associatedtype V: Hashable

    var vertices: [V] { get set }
    func index(of vertex: V) -> Int?
}

extension Graph {
    public func index(of vertex: V) -> Int? {
        return vertices.index(of: vertex)
    }
}

extension Graph {
    public typealias Iterator = AnyIterator<V>
    public func makeIterator() -> Iterator {
        return Iterator { nil }
    }
}

Removing either extension bypasses the issue.

The problem is present both in Xcode and swift build. Here's Xcode's build log:

CompileSwift normal x86_64 /Directory/Graph/Sources/Graph/Graph.swift
    cd /Directory/Graph
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file /Directory/Graph/Sources/Graph/Graph.swift -target x86_64-apple-macosx10.13 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -I /Users/W/Library/Developer/Xcode/DerivedData/Graph-fxbjxbbodaetmkflkbwpyfzzoxzo/Build/Products/Debug -F /Users/W/Library/Developer/Xcode/DerivedData/Graph-fxbjxbbodaetmkflkbwpyfzzoxzo/Build/Products/Debug -enable-testing -g -import-underlying-module -module-cache-path /Users/W/Library/Developer/Xcode/DerivedData/ModuleCache -swift-version 4 -enforce-exclusivity=checked -D DEBUG -serialize-debugging-options -report-errors-to-debugger -Xcc -I/Users/W/Library/Developer/Xcode/DerivedData/Graph-fxbjxbbodaetmkflkbwpyfzzoxzo/Build/Intermediates.noindex/Graph.build/Debug/Graph.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/W/Library/Developer/Xcode/DerivedData/Graph-fxbjxbbodaetmkflkbwpyfzzoxzo/Build/Intermediates.noindex/Graph.build/Debug/Graph.build/Graph-generated-files.hmap -Xcc -I/Users/W/Library/Developer/Xcode/DerivedData/Graph-fxbjxbbodaetmkflkbwpyfzzoxzo/Build/Intermediates.noindex/Graph.build/Debug/Graph.build/Graph-own-target-headers.hmap -Xcc -I/Users/W/Library/Developer/Xcode/DerivedData/Graph-fxbjxbbodaetmkflkbwpyfzzoxzo/Build/Intermediates.noindex/Graph.build/Debug/Graph.build/Graph-all-non-framework-target-headers.hmap -Xcc -ivfsoverlay -Xcc /Users/W/Library/Developer/Xcode/DerivedData/Graph-fxbjxbbodaetmkflkbwpyfzzoxzo/Build/Intermediates.noindex/Graph.build/all-product-headers.yaml -Xcc -iquote -Xcc /Users/W/Library/Developer/Xcode/DerivedData/Graph-fxbjxbbodaetmkflkbwpyfzzoxzo/Build/Intermediates.noindex/Graph.build/Debug/Graph.build/Graph-project-headers.hmap -Xcc -I/Users/W/Library/Developer/Xcode/DerivedData/Graph-fxbjxbbodaetmkflkbwpyfzzoxzo/Build/Products/Debug/include -Xcc -I/Users/W/Library/Developer/Xcode/DerivedData/Graph-fxbjxbbodaetmkflkbwpyfzzoxzo/Build/Intermediates.noindex/Graph.build/Debug/Graph.build/DerivedSources/x86_64 -Xcc -I/Users/W/Library/Developer/Xcode/DerivedData/Graph-fxbjxbbodaetmkflkbwpyfzzoxzo/Build/Intermediates.noindex/Graph.build/Debug/Graph.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -ivfsoverlay -Xcc /Users/W/Library/Developer/Xcode/DerivedData/Graph-fxbjxbbodaetmkflkbwpyfzzoxzo/Build/Intermediates.noindex/Graph.build/Debug/Graph.build/unextended-module-overlay.yaml -Xcc -working-directory/Directory/Graph -emit-module-doc-path /Users/W/Library/Developer/Xcode/DerivedData/Graph-fxbjxbbodaetmkflkbwpyfzzoxzo/Build/Intermediates.noindex/Graph.build/Debug/Graph.build/Objects-normal/x86_64/Graph~partial.swiftdoc -serialize-diagnostics-path /Users/W/Library/Developer/Xcode/DerivedData/Graph-fxbjxbbodaetmkflkbwpyfzzoxzo/Build/Intermediates.noindex/Graph.build/Debug/Graph.build/Objects-normal/x86_64/Graph.dia -Onone -parse-as-library -module-name Graph -emit-module-path /Users/W/Library/Developer/Xcode/DerivedData/Graph-fxbjxbbodaetmkflkbwpyfzzoxzo/Build/Intermediates.noindex/Graph.build/Debug/Graph.build/Objects-normal/x86_64/Graph~partial.swiftmodule -emit-dependencies-path /Users/W/Library/Developer/Xcode/DerivedData/Graph-fxbjxbbodaetmkflkbwpyfzzoxzo/Build/Intermediates.noindex/Graph.build/Debug/Graph.build/Objects-normal/x86_64/Graph.d -emit-reference-dependencies-path /Users/W/Library/Developer/Xcode/DerivedData/Graph-fxbjxbbodaetmkflkbwpyfzzoxzo/Build/Intermediates.noindex/Graph.build/Debug/Graph.build/Objects-normal/x86_64/Graph.swiftdeps -o /Users/W/Library/Developer/Xcode/DerivedData/Graph-fxbjxbbodaetmkflkbwpyfzzoxzo/Build/Intermediates.noindex/Graph.build/Debug/Graph.build/Objects-normal/x86_64/Graph.o -index-store-path /Users/W/Library/Developer/Xcode/DerivedData/Graph-fxbjxbbodaetmkflkbwpyfzzoxzo/Index/DataStore -index-system-modules

0  swift                    0x000000010805936a PrintStackTraceSignalHandler(void*) + 42
1  swift                    0x00000001080587a6 SignalHandler(int) + 662
2  libsystem_platform.dylib 0x00007fff648c8f5a _sigtramp + 26
3  libsystem_platform.dylib 000000000000000000 _sigtramp + 2608033984
4  swift                    0x0000000104aff45f swift::irgen::MetadataPath::follow(swift::irgen::IRGenFunction&, swift::irgen::LocalTypeDataKey, llvm::Value*, swift::EncodedSequence<swift::irgen::MetadataPath::Component>::iterator, swift::EncodedSequence<swift::irgen::MetadataPath::Component>::iterator, swift::EncodedSequence<swift::irgen::MetadataPath::Component>::Map<llvm::Value*>*) + 399
5  swift                    0x00000001049fc810 swift::irgen::emitArchetypeWitnessTableRef(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::ArchetypeType>, swift::ProtocolDecl*) + 1264
6  swift                    0x0000000104b025f3 swift::irgen::emitWitnessTableRef(swift::irgen::IRGenFunction&, swift::CanType, llvm::Value**, swift::ProtocolConformanceRef) + 83
7  swift                    0x0000000104b02b6f swift::irgen::emitGenericRequirementFromSubstitutions(swift::irgen::IRGenFunction&, swift::CanGenericSignature, swift::ModuleDecl&, swift::irgen::GenericRequirement, swift::SubstitutionMap const&) + 175
8  swift                    0x0000000104b02a31 void llvm::function_ref<void (swift::irgen::GenericRequirement)>::callback_fn<(anonymous namespace)::EmitPolymorphicArguments::emit(swift::SubstitutionMap const&, swift::irgen::WitnessMetadata*, swift::irgen::Explosion&)::$_14>(long, swift::irgen::GenericRequirement) + 33
9  swift                    0x0000000104b00e82 void llvm::function_ref<void (swift::irgen::GenericRequirement)>::callback_fn<(anonymous namespace)::PolymorphicConvention::enumerateUnfulfilledRequirements(llvm::function_ref<void (swift::irgen::GenericRequirement)> const&)::$_7>(long, swift::irgen::GenericRequirement) + 162
10 swift                    0x0000000104af809b swift::irgen::enumerateGenericSignatureRequirements(swift::CanGenericSignature, llvm::function_ref<void (swift::irgen::GenericRequirement)> const&) + 283
11 swift                    0x0000000104b02874 swift::irgen::emitPolymorphicArguments(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::SILFunctionType>, swift::SubstitutionMap const&, swift::irgen::WitnessMetadata*, swift::irgen::Explosion&) + 420
12 swift                    0x0000000104b7559a (anonymous namespace)::IRGenSILFunction::visitFullApplySite(swift::FullApplySite) + 3130
13 swift                    0x0000000104b537a0 swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 9120
14 swift                    0x0000000104a5904e swift::irgen::IRGenerator::emitGlobalTopLevel() + 1022
15 swift                    0x0000000104b358fb performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, llvm::LLVMContext&, swift::SourceFile*, llvm::GlobalVariable**, unsigned int) + 1243
16 swift                    0x00000001049b6bab performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 16715
17 swift                    0x00000001049b11f4 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7716
18 swift                    0x0000000104965e78 main + 12248
19 libdyld.dylib            0x00007fff64647115 start + 1
20 libdyld.dylib            0x000000000000004d start + 2610663225
Stack dump:
0.  Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file /Directory/Graph/Sources/Graph/Graph.swift -target x86_64-apple-macosx10.13 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -I /Users/W/Library/Developer/Xcode/DerivedData/Graph-fxbjxbbodaetmkflkbwpyfzzoxzo/Build/Products/Debug -F /Users/W/Library/Developer/Xcode/DerivedData/Graph-fxbjxbbodaetmkflkbwpyfzzoxzo/Build/Products/Debug -enable-testing -g -import-underlying-module -module-cache-path /Users/W/Library/Developer/Xcode/DerivedData/ModuleCache -swift-version 4 -enforce-exclusivity=checked -D DEBUG -serialize-debugging-options -report-errors-to-debugger -Xcc -I/Users/W/Library/Developer/Xcode/DerivedData/Graph-fxbjxbbodaetmkflkbwpyfzzoxzo/Build/Intermediates.noindex/Graph.build/Debug/Graph.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/W/Library/Developer/Xcode/DerivedData/Graph-fxbjxbbodaetmkflkbwpyfzzoxzo/Build/Intermediates.noindex/Graph.build/Debug/Graph.build/Graph-generated-files.hmap -Xcc -I/Users/W/Library/Developer/Xcode/DerivedData/Graph-fxbjxbbodaetmkflkbwpyfzzoxzo/Build/Intermediates.noindex/Graph.build/Debug/Graph.build/Graph-own-target-headers.hmap -Xcc -I/Users/W/Library/Developer/Xcode/DerivedData/Graph-fxbjxbbodaetmkflkbwpyfzzoxzo/Build/Intermediates.noindex/Graph.build/Debug/Graph.build/Graph-all-non-framework-target-headers.hmap -Xcc -ivfsoverlay -Xcc /Users/W/Library/Developer/Xcode/DerivedData/Graph-fxbjxbbodaetmkflkbwpyfzzoxzo/Build/Intermediates.noindex/Graph.build/all-product-headers.yaml -Xcc -iquote -Xcc /Users/W/Library/Developer/Xcode/DerivedData/Graph-fxbjxbbodaetmkflkbwpyfzzoxzo/Build/Intermediates.noindex/Graph.build/Debug/Graph.build/Graph-project-headers.hmap -Xcc -I/Users/W/Library/Developer/Xcode/DerivedData/Graph-fxbjxbbodaetmkflkbwpyfzzoxzo/Build/Products/Debug/include -Xcc -I/Users/W/Library/Developer/Xcode/DerivedData/Graph-fxbjxbbodaetmkflkbwpyfzzoxzo/Build/Intermediates.noindex/Graph.build/Debug/Graph.build/DerivedSources/x86_64 -Xcc -I/Users/W/Library/Developer/Xcode/DerivedData/Graph-fxbjxbbodaetmkflkbwpyfzzoxzo/Build/Intermediates.noindex/Graph.build/Debug/Graph.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -ivfsoverlay -Xcc /Users/W/Library/Developer/Xcode/DerivedData/Graph-fxbjxbbodaetmkflkbwpyfzzoxzo/Build/Intermediates.noindex/Graph.build/Debug/Graph.build/unextended-module-overlay.yaml -Xcc -working-directory/Directory/Graph -emit-module-doc-path /Users/W/Library/Developer/Xcode/DerivedData/Graph-fxbjxbbodaetmkflkbwpyfzzoxzo/Build/Intermediates.noindex/Graph.build/Debug/Graph.build/Objects-normal/x86_64/Graph~partial.swiftdoc -serialize-diagnostics-path /Users/W/Library/Developer/Xcode/DerivedData/Graph-fxbjxbbodaetmkflkbwpyfzzoxzo/Build/Intermediates.noindex/Graph.build/Debug/Graph.build/Objects-normal/x86_64/Graph.dia -Onone -parse-as-library -module-name Graph -emit-module-path /Users/W/Library/Developer/Xcode/DerivedData/Graph-fxbjxbbodaetmkflkbwpyfzzoxzo/Build/Intermediates.noindex/Graph.build/Debug/Graph.build/Objects-normal/x86_64/Graph~partial.swiftmodule -emit-dependencies-path /Users/W/Library/Developer/Xcode/DerivedData/Graph-fxbjxbbodaetmkflkbwpyfzzoxzo/Build/Intermediates.noindex/Graph.build/Debug/Graph.build/Objects-normal/x86_64/Graph.d -emit-reference-dependencies-path /Users/W/Library/Developer/Xcode/DerivedData/Graph-fxbjxbbodaetmkflkbwpyfzzoxzo/Build/Intermediates.noindex/Graph.build/Debug/Graph.build/Objects-normal/x86_64/Graph.swiftdeps -o /Users/W/Library/Developer/Xcode/DerivedData/Graph-fxbjxbbodaetmkflkbwpyfzzoxzo/Build/Intermediates.noindex/Graph.build/Debug/Graph.build/Objects-normal/x86_64/Graph.o -index-store-path /Users/W/Library/Developer/Xcode/DerivedData/Graph-fxbjxbbodaetmkflkbwpyfzzoxzo/Index/DataStore -index-system-modules 
1.  While emitting IR SIL function "@_T05GraphAAPAAE5indexSiSg1VQz2of_tF".
 for 'index(of:)' at /Directory/Graph/Sources/Graph/Graph.swift:9:12
@belkadan
Copy link
Contributor

Looks like it no longer crashes on master, which probably means it'll be fixed in Swift 4.1:

<stdin>:16:35: error: 'Iterator' is ambiguous for type lookup in this context
    public func makeIterator() -> Iterator {
                                  ^~~~~~~~
<stdin>:15:22: note: found this candidate
    public typealias Iterator = AnyIterator<V>
                     ^
Swift.Collection:237:20: note: found this candidate
    associatedtype Iterator = IndexingIterator<Self>

@DougGregor, confirm/deny?

@belkadan
Copy link
Contributor

Actually, this still doesn't seem like it's doing the right thing. It should be using your typealias, I would assume.

@swift-ci create

@DougGregor
Copy link
Member

For reference, this no longer crashes in 4.1, but I'd like to hold the bug open to address the ambiguity.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
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
Projects
None yet
Development

No branches or pull requests

3 participants