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-2796] Generics compiler crash regression #45400

Closed
tkrajacic opened this issue Sep 29, 2016 · 11 comments
Closed

[SR-2796] Generics compiler crash regression #45400

tkrajacic opened this issue Sep 29, 2016 · 11 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 IRGen LLVM IR generation regression swift 3.0

Comments

@tkrajacic
Copy link

Previous ID SR-2796
Radar rdar://problem/28544316
Original Reporter @tkrajacic
Type Bug
Status Closed
Resolution Done

Attachment: Download

Environment

macOS Sierra, Xcode Version 8.0 (8A218a), latest Macbook

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 3.0Regression, CompilerCrash, IRGen
Assignee @slavapestov
Priority Medium

md5: 3040e439e4846fca8170995cf23cde23

Issue Description:

Similar to SR-2101 which is fixed in the latest snapshot 2016-09-27-a this slightly enhanced example still crashes. I have attached an Xcode project that will immediately crash in Xcode 8 (MAS version) using even that latest snapshot 2016-09-27-a.
Again, this worked without a problem in Swift 2.3 (and is sadly keeping me from adopting Swift 3 in that project so far)

@huonw
Copy link
Mannequin

huonw mannequin commented Oct 11, 2016

A smaller example created by creduce-ing `Crasher.swift`:

class PropertyDataSource<PropertyHosting> {}
protocol TableViewCellFactoryType {
    associatedtype Item
}
protocol PropertyHosting {
    associatedtype PType: EntityOwned
}
protocol EntityOwned {
    associatedtype Owner
}
class PropertyTableViewAdapter<Factory: TableViewCellFactoryType>
    where Factory.Item.Owner: PropertyHosting, Factory.Item.Owner.PType == Factory.Item
{
    typealias Item = Factory.Item
    let dataManager: PropertyDataSource<Item.Owner>
    init(dataManager: PropertyDataSource<Item.Owner>) {
        self.dataManager = dataManager
    }
}

@swift-ci
Copy link
Collaborator

Comment by Brian Blanchard (JIRA)

I am also having the same issues. I am doing something very similar to @huonw. One thing that I have found, if I turn on whole module optimization the app will build fine but the compiler will seg fault in debug mode.

Here is my stack trace:

0  swift                    0x000000010e280a3d PrintStackTraceSignalHandler(void*) + 45
1  swift                    0x000000010e280466 SignalHandler(int) + 470
2  libsystem_platform.dylib 0x00007fff8f495bba _sigtramp + 26
3  libsystem_platform.dylib 0x0000000000000003 _sigtramp + 1891017827
4  swift                    0x000000010c001cb2 swift::GenericParamList::addNestedArchetypes(swift::ArchetypeType*, llvm::SmallPtrSetImpl<swift::ArchetypeType*>&, llvm::SmallVectorImpl<swift::ArchetypeType*>&) + 34
5  swift                    0x000000010c0020b2 swift::GenericParamList::deriveAllArchetypes(llvm::ArrayRef<swift::GenericTypeParamDecl*>, llvm::SmallVectorImpl<swift::ArchetypeType*>&) + 594
6  swift                    0x000000010bc103bd swift::ModuleFile::maybeReadGenericParams(swift::DeclContext*, llvm::BitstreamCursor&, swift::GenericParamList*) + 573
7  swift                    0x000000010bc0521a swift::ModuleFile::getDecl(llvm::PointerEmbeddedInt<unsigned int, 31>, llvm::Optional<swift::DeclContext*>) + 14570
8  swift                    0x000000010bc0df31 swift::ModuleFile::getType(llvm::PointerEmbeddedInt<unsigned int, 31>) + 2481
9  swift                    0x000000010bc88758 swift::SerializedModuleLoader::loadObjCMethods(swift::ClassDecl*, swift::ObjCSelector, bool, unsigned int, llvm::TinyPtrVector<swift::AbstractFunctionDecl*>&) + 264
10 swift                    0x000000010c04cedf swift::ClassDecl::lookupDirect(swift::ObjCSelector, bool) + 255
11 swift                    0x000000010bd0208c (anonymous namespace)::SwiftDeclConverter::methodAlreadyImported(swift::ObjCSelector, bool, swift::DeclContext*) + 412
12 swift                    0x000000010bd01af8 (anonymous namespace)::SwiftDeclConverter::importConstructor(clang::ObjCMethodDecl const*, swift::DeclContext*, bool, llvm::Optional<swift::CtorInitializerKind>, bool) + 200
13 swift                    0x000000010bce7869 (anonymous namespace)::SwiftDeclConverter::VisitObjCMethodDecl(clang::ObjCMethodDecl const*, swift::DeclContext*, bool) + 89
14 swift                    0x000000010bcdc23b clang::declvisitor::Base<clang::declvisitor::make_const_ptr, (anonymous namespace)::SwiftDeclConverter, swift::Decl*>::Visit(clang::Decl const*) + 3547
15 swift                    0x000000010bcdad30 swift::ClangImporter::Implementation::importDeclAndCacheImpl(clang::NamedDecl const*, bool, bool) + 928
16 swift                    0x000000010bd09782 (anonymous namespace)::SwiftDeclConverter::importObjCMembers(clang::ObjCContainerDecl const*, swift::DeclContext*, llvm::SmallPtrSet<swift::Decl*, 4u>&, llvm::SmallVectorImpl<swift::Decl*>&) + 354
17 swift                    0x000000010bd08482 swift::ClangImporter::Implementation::loadAllMembers(swift::Decl*, unsigned long long) + 2066
18 swift                    0x000000010c04c21f swift::NominalTypeDecl::lookupDirect(swift::DeclName, bool) + 303
19 swift                    0x000000010c04a3b3 swift::DeclContext::lookupQualified(swift::Type, swift::DeclName, swift::NLOptions, swift::LazyResolver*, llvm::SmallVectorImpl<swift::ValueDecl*>&) const + 4051
20 swift                    0x000000010bceb168 (anonymous namespace)::SwiftDeclConverter::VisitObjCPropertyDecl(clang::ObjCPropertyDecl const*, swift::DeclContext*) + 360
21 swift                    0x000000010bcdc21f clang::declvisitor::Base<clang::declvisitor::make_const_ptr, (anonymous namespace)::SwiftDeclConverter, swift::Decl*>::Visit(clang::Decl const*) + 3519
22 swift                    0x000000010bcdad30 swift::ClangImporter::Implementation::importDeclAndCacheImpl(clang::NamedDecl const*, bool, bool) + 928
23 swift                    0x000000010bd09782 (anonymous namespace)::SwiftDeclConverter::importObjCMembers(clang::ObjCContainerDecl const*, swift::DeclContext*, llvm::SmallPtrSet<swift::Decl*, 4u>&, llvm::SmallVectorImpl<swift::Decl*>&) + 354
24 swift                    0x000000010bd08482 swift::ClangImporter::Implementation::loadAllMembers(swift::Decl*, unsigned long long) + 2066
25 swift                    0x000000010c04c17a swift::NominalTypeDecl::lookupDirect(swift::DeclName, bool) + 138
26 swift                    0x000000010c04a3b3 swift::DeclContext::lookupQualified(swift::Type, swift::DeclName, swift::NLOptions, swift::LazyResolver*, llvm::SmallVectorImpl<swift::ValueDecl*>&) const + 4051
27 swift                    0x000000010bceb168 (anonymous namespace)::SwiftDeclConverter::VisitObjCPropertyDecl(clang::ObjCPropertyDecl const*, swift::DeclContext*) + 360
28 swift                    0x000000010bcdc21f clang::declvisitor::Base<clang::declvisitor::make_const_ptr, (anonymous namespace)::SwiftDeclConverter, swift::Decl*>::Visit(clang::Decl const*) + 3519
29 swift                    0x000000010bcdad30 swift::ClangImporter::Implementation::importDeclAndCacheImpl(clang::NamedDecl const*, bool, bool) + 928
30 swift                    0x000000010bd09782 (anonymous namespace)::SwiftDeclConverter::importObjCMembers(clang::ObjCContainerDecl const*, swift::DeclContext*, llvm::SmallPtrSet<swift::Decl*, 4u>&, llvm::SmallVectorImpl<swift::Decl*>&) + 354
31 swift                    0x000000010bd08482 swift::ClangImporter::Implementation::loadAllMembers(swift::Decl*, unsigned long long) + 2066
32 swift                    0x000000010c04c17a swift::NominalTypeDecl::lookupDirect(swift::DeclName, bool) + 138
33 swift                    0x000000010c04a3b3 swift::DeclContext::lookupQualified(swift::Type, swift::DeclName, swift::NLOptions, swift::LazyResolver*, llvm::SmallVectorImpl<swift::ValueDecl*>&) const + 4051
34 swift                    0x000000010bceb168 (anonymous namespace)::SwiftDeclConverter::VisitObjCPropertyDecl(clang::ObjCPropertyDecl const*, swift::DeclContext*) + 360
35 swift                    0x000000010bcdc21f clang::declvisitor::Base<clang::declvisitor::make_const_ptr, (anonymous namespace)::SwiftDeclConverter, swift::Decl*>::Visit(clang::Decl const*) + 3519
36 swift                    0x000000010bcdad30 swift::ClangImporter::Implementation::importDeclAndCacheImpl(clang::NamedDecl const*, bool, bool) + 928
37 swift                    0x000000010bd09782 (anonymous namespace)::SwiftDeclConverter::importObjCMembers(clang::ObjCContainerDecl const*, swift::DeclContext*, llvm::SmallPtrSet<swift::Decl*, 4u>&, llvm::SmallVectorImpl<swift::Decl*>&) + 354
38 swift                    0x000000010bd08482 swift::ClangImporter::Implementation::loadAllMembers(swift::Decl*, unsigned long long) + 2066
39 swift                    0x000000010c04c17a swift::NominalTypeDecl::lookupDirect(swift::DeclName, bool) + 138
40 swift                    0x000000010c04a3b3 swift::DeclContext::lookupQualified(swift::Type, swift::DeclName, swift::NLOptions, swift::LazyResolver*, llvm::SmallVectorImpl<swift::ValueDecl*>&) const + 4051
41 swift                    0x000000010bceb168 (anonymous namespace)::SwiftDeclConverter::VisitObjCPropertyDecl(clang::ObjCPropertyDecl const*, swift::DeclContext*) + 360
42 swift                    0x000000010bcdc21f clang::declvisitor::Base<clang::declvisitor::make_const_ptr, (anonymous namespace)::SwiftDeclConverter, swift::Decl*>::Visit(clang::Decl const*) + 3519
43 swift                    0x000000010bcdad30 swift::ClangImporter::Implementation::importDeclAndCacheImpl(clang::NamedDecl const*, bool, bool) + 928
44 swift                    0x000000010bd09782 (anonymous namespace)::SwiftDeclConverter::importObjCMembers(clang::ObjCContainerDecl const*, swift::DeclContext*, llvm::SmallPtrSet<swift::Decl*, 4u>&, llvm::SmallVectorImpl<swift::Decl*>&) + 354
45 swift                    0x000000010bd08482 swift::ClangImporter::Implementation::loadAllMembers(swift::Decl*, unsigned long long) + 2066
46 swift                    0x000000010c04c17a swift::NominalTypeDecl::lookupDirect(swift::DeclName, bool) + 138
47 swift                    0x000000010c04a3b3 swift::DeclContext::lookupQualified(swift::Type, swift::DeclName, swift::NLOptions, swift::LazyResolver*, llvm::SmallVectorImpl<swift::ValueDecl*>&) const + 4051
48 swift                    0x000000010bceb168 (anonymous namespace)::SwiftDeclConverter::VisitObjCPropertyDecl(clang::ObjCPropertyDecl const*, swift::DeclContext*) + 360
49 swift                    0x000000010bcdc21f clang::declvisitor::Base<clang::declvisitor::make_const_ptr, (anonymous namespace)::SwiftDeclConverter, swift::Decl*>::Visit(clang::Decl const*) + 3519
50 swift                    0x000000010bcdad30 swift::ClangImporter::Implementation::importDeclAndCacheImpl(clang::NamedDecl const*, bool, bool) + 928
51 swift                    0x000000010bd09782 (anonymous namespace)::SwiftDeclConverter::importObjCMembers(clang::ObjCContainerDecl const*, swift::DeclContext*, llvm::SmallPtrSet<swift::Decl*, 4u>&, llvm::SmallVectorImpl<swift::Decl*>&) + 354
52 swift                    0x000000010bd08482 swift::ClangImporter::Implementation::loadAllMembers(swift::Decl*, unsigned long long) + 2066
53 swift                    0x000000010c04c17a swift::NominalTypeDecl::lookupDirect(swift::DeclName, bool) + 138
54 swift                    0x000000010c04a3b3 swift::DeclContext::lookupQualified(swift::Type, swift::DeclName, swift::NLOptions, swift::LazyResolver*, llvm::SmallVectorImpl<swift::ValueDecl*>&) const + 4051
55 swift                    0x000000010bceb168 (anonymous namespace)::SwiftDeclConverter::VisitObjCPropertyDecl(clang::ObjCPropertyDecl const*, swift::DeclContext*) + 360
56 swift                    0x000000010bcdc21f clang::declvisitor::Base<clang::declvisitor::make_const_ptr, (anonymous namespace)::SwiftDeclConverter, swift::Decl*>::Visit(clang::Decl const*) + 3519
57 swift                    0x000000010bcdad30 swift::ClangImporter::Implementation::importDeclAndCacheImpl(clang::NamedDecl const*, bool, bool) + 928
58 swift                    0x000000010bd09782 (anonymous namespace)::SwiftDeclConverter::importObjCMembers(clang::ObjCContainerDecl const*, swift::DeclContext*, llvm::SmallPtrSet<swift::Decl*, 4u>&, llvm::SmallVectorImpl<swift::Decl*>&) + 354
59 swift                    0x000000010bd08482 swift::ClangImporter::Implementation::loadAllMembers(swift::Decl*, unsigned long long) + 2066
60 swift                    0x000000010c04c17a swift::NominalTypeDecl::lookupDirect(swift::DeclName, bool) + 138
61 swift                    0x000000010c04a3b3 swift::DeclContext::lookupQualified(swift::Type, swift::DeclName, swift::NLOptions, swift::LazyResolver*, llvm::SmallVectorImpl<swift::ValueDecl*>&) const + 4051
62 swift                    0x000000010bceb168 (anonymous namespace)::SwiftDeclConverter::VisitObjCPropertyDecl(clang::ObjCPropertyDecl const*, swift::DeclContext*) + 360
63 swift                    0x000000010bcdc21f clang::declvisitor::Base<clang::declvisitor::make_const_ptr, (anonymous namespace)::SwiftDeclConverter, swift::Decl*>::Visit(clang::Decl const*) + 3519
64 swift                    0x000000010bcdad30 swift::ClangImporter::Implementation::importDeclAndCacheImpl(clang::NamedDecl const*, bool, bool) + 928
65 swift                    0x000000010bd09782 (anonymous namespace)::SwiftDeclConverter::importObjCMembers(clang::ObjCContainerDecl const*, swift::DeclContext*, llvm::SmallPtrSet<swift::Decl*, 4u>&, llvm::SmallVectorImpl<swift::Decl*>&) + 354
66 swift                    0x000000010bd08482 swift::ClangImporter::Implementation::loadAllMembers(swift::Decl*, unsigned long long) + 2066
67 swift                    0x000000010c04c17a swift::NominalTypeDecl::lookupDirect(swift::DeclName, bool) + 138
68 swift                    0x000000010c04a3b3 swift::DeclContext::lookupQualified(swift::Type, swift::DeclName, swift::NLOptions, swift::LazyResolver*, llvm::SmallVectorImpl<swift::ValueDecl*>&) const + 4051
69 swift                    0x000000010bceb168 (anonymous namespace)::SwiftDeclConverter::VisitObjCPropertyDecl(clang::ObjCPropertyDecl const*, swift::DeclContext*) + 360
70 swift                    0x000000010bcdc21f clang::declvisitor::Base<clang::declvisitor::make_const_ptr, (anonymous namespace)::SwiftDeclConverter, swift::Decl*>::Visit(clang::Decl const*) + 3519
71 swift                    0x000000010bcdad30 swift::ClangImporter::Implementation::importDeclAndCacheImpl(clang::NamedDecl const*, bool, bool) + 928
72 swift                    0x000000010bd09782 (anonymous namespace)::SwiftDeclConverter::importObjCMembers(clang::ObjCContainerDecl const*, swift::DeclContext*, llvm::SmallPtrSet<swift::Decl*, 4u>&, llvm::SmallVectorImpl<swift::Decl*>&) + 354
73 swift                    0x000000010bd08482 swift::ClangImporter::Implementation::loadAllMembers(swift::Decl*, unsigned long long) + 2066
74 swift                    0x000000010c04c17a swift::NominalTypeDecl::lookupDirect(swift::DeclName, bool) + 138
75 swift                    0x000000010c04a3b3 swift::DeclContext::lookupQualified(swift::Type, swift::DeclName, swift::NLOptions, swift::LazyResolver*, llvm::SmallVectorImpl<swift::ValueDecl*>&) const + 4051
76 swift                    0x000000010bceb168 (anonymous namespace)::SwiftDeclConverter::VisitObjCPropertyDecl(clang::ObjCPropertyDecl const*, swift::DeclContext*) + 360
77 swift                    0x000000010bcdc21f clang::declvisitor::Base<clang::declvisitor::make_const_ptr, (anonymous namespace)::SwiftDeclConverter, swift::Decl*>::Visit(clang::Decl const*) + 3519
78 swift                    0x000000010bcdad30 swift::ClangImporter::Implementation::importDeclAndCacheImpl(clang::NamedDecl const*, bool, bool) + 928
79 swift                    0x000000010bd09782 (anonymous namespace)::SwiftDeclConverter::importObjCMembers(clang::ObjCContainerDecl const*, swift::DeclContext*, llvm::SmallPtrSet<swift::Decl*, 4u>&, llvm::SmallVectorImpl<swift::Decl*>&) + 354
80 swift                    0x000000010bd08482 swift::ClangImporter::Implementation::loadAllMembers(swift::Decl*, unsigned long long) + 2066
81 swift                    0x000000010c04c17a swift::NominalTypeDecl::lookupDirect(swift::DeclName, bool) + 138
82 swift                    0x000000010bc0c2f8 swift::ModuleFile::getDecl(llvm::PointerEmbeddedInt<unsigned int, 31>, llvm::Optional<swift::DeclContext*>) + 43464
83 swift                    0x000000010bc09689 swift::ModuleFile::getDecl(llvm::PointerEmbeddedInt<unsigned int, 31>, llvm::Optional<swift::DeclContext*>) + 32089
84 swift                    0x000000010bc09689 swift::ModuleFile::getDecl(llvm::PointerEmbeddedInt<unsigned int, 31>, llvm::Optional<swift::DeclContext*>) + 32089
85 swift                    0x000000010bc16367 swift::ModuleFile::loadAllMembers(swift::Decl*, unsigned long long) + 647
86 swift                    0x000000010c04c21f swift::NominalTypeDecl::lookupDirect(swift::DeclName, bool) + 303
87 swift                    0x000000010bc0c2f8 swift::ModuleFile::getDecl(llvm::PointerEmbeddedInt<unsigned int, 31>, llvm::Optional<swift::DeclContext*>) + 43464
88 swift                    0x000000010bc0d757 swift::ModuleFile::getType(llvm::PointerEmbeddedInt<unsigned int, 31>) + 471
89 swift                    0x000000010bc0deaf swift::ModuleFile::getType(llvm::PointerEmbeddedInt<unsigned int, 31>) + 2351
90 swift                    0x000000010bc0deaf swift::ModuleFile::getType(llvm::PointerEmbeddedInt<unsigned int, 31>) + 2351
91 swift                    0x000000010bc0deaf swift::ModuleFile::getType(llvm::PointerEmbeddedInt<unsigned int, 31>) + 2351
92 swift                    0x000000010bc0f2c6 swift::ModuleFile::getType(llvm::PointerEmbeddedInt<unsigned int, 31>) + 7494
93 swift                    0x000000010bc06eb6 swift::ModuleFile::getDecl(llvm::PointerEmbeddedInt<unsigned int, 31>, llvm::Optional<swift::DeclContext*>) + 21894
94 swift                    0x000000010bc10851 swift::ModuleFile::maybeReadGenericParams(swift::DeclContext*, llvm::BitstreamCursor&, swift::GenericParamList*) + 1745
95 swift                    0x000000010bc0521a swift::ModuleFile::getDecl(llvm::PointerEmbeddedInt<unsigned int, 31>, llvm::Optional<swift::DeclContext*>) + 14570
96 swift                    0x000000010bc0df31 swift::ModuleFile::getType(llvm::PointerEmbeddedInt<unsigned int, 31>) + 2481
97 swift                    0x000000010bc084e5 swift::ModuleFile::getDecl(llvm::PointerEmbeddedInt<unsigned int, 31>, llvm::Optional<swift::DeclContext*>) + 27573
98 swift                    0x000000010bc31e4f swift::ModuleFile::getTopLevelDecls(llvm::SmallVectorImpl<swift::Decl*>&) + 2287
99 swift                    0x000000010b962710 swift::SILPassManager::SILPassManager(swift::SILModule*, llvm::StringRef) + 1344
100 swift                    0x000000010b9672ef swift::runSILDiagnosticPasses(swift::SILModule&) + 159
101 swift                    0x000000010b62dcb1 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*) + 19761
102 swift                    0x000000010b626f70 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 17856
103 swift                    0x000000010b5e393e main + 8302
104 libdyld.dylib            0x00007fff8f288255 start + 1

@slavapestov
Copy link
Member

Unfortunately still crashes on master, except the error is different:

Slavas-MBP:swift slava$ ../build/Ninja-ReleaseAssert/swift-macosx-x86_64/bin/swiftc reg.swift 
0  swift                    0x00000001115c3cc6 SignalHandler(int) + 454
1  libsystem_platform.dylib 0x00007fffcb872bba _sigtramp + 26
2  swift                    0x000000010ef10023 swift::Type::transform(llvm::function_ref<swift::Type (swift::Type)>) const + 67
3  swift                    0x000000010ef13251 swift::Type llvm::function_ref<swift::Type (swift::Type)>::callback_fn<substType(swift::Type, llvm::PointerUnion<swift::ModuleDecl*, swift::SubstitutionMap const*>, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>)::$_11>(long, swift::Type) + 209
4  swift                    0x000000010ef10024 swift::Type::transform(llvm::function_ref<swift::Type (swift::Type)>) const + 68
5  swift                    0x000000010ef0f7db swift::Type::subst(swift::ModuleDecl*, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, swift::OptionSet<swift::SubstFlags, unsigned int>) const + 107
6  swift                    0x000000010eeca57a swift::GenericEnvironment::mapTypeIntoContext(swift::ModuleDecl*, swift::Type) const + 42
7  swift                    0x000000010eea90ac swift::AbstractTypeParamDecl::getConformingProtocols() const + 92
8  swift                    0x000000010e4fe7a5 findConformanceDeclaration(llvm::ArrayRef<swift::ProtocolDecl*>, swift::AssociatedTypeDecl*, swift::ProtocolDecl*) + 37
9  swift                    0x000000010e500c1a llvm::Value* llvm::function_ref<llvm::Value* (unsigned int)>::callback_fn<swift::irgen::emitArchetypeWitnessTableRef(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::ArchetypeType>, swift::ProtocolDecl*)::$_0>(long, unsigned int) + 282
10 swift                    0x000000010e5d2961 swift::irgen::emitImpliedWitnessTableRef(swift::irgen::IRGenFunction&, llvm::ArrayRef<swift::irgen::ProtocolEntry>, swift::ProtocolDecl*, llvm::function_ref<llvm::Value* (unsigned int)> const&) + 273
11 swift                    0x000000010e4fe5e0 swift::irgen::emitArchetypeWitnessTableRef(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::ArchetypeType>, swift::ProtocolDecl*) + 176
12 swift                    0x000000010e4fe4bd swift::irgen::emitAssociatedTypeMetadataRef(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::ArchetypeType>, swift::AssociatedTypeDecl*) + 93
13 swift                    0x000000010e4fe3cc swift::irgen::emitArchetypeTypeMetadataRef(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::ArchetypeType>) + 108
14 swift                    0x000000010e4fe6ee swift::irgen::emitAssociatedTypeWitnessTableRef(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::ArchetypeType>, swift::AssociatedTypeDecl*, llvm::Value*, swift::ProtocolDecl*) + 158
15 swift                    0x000000010e500cba llvm::Value* llvm::function_ref<llvm::Value* (unsigned int)>::callback_fn<swift::irgen::emitArchetypeWitnessTableRef(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::ArchetypeType>, swift::ProtocolDecl*)::$_0>(long, unsigned int) + 442
16 swift                    0x000000010e5d2961 swift::irgen::emitImpliedWitnessTableRef(swift::irgen::IRGenFunction&, llvm::ArrayRef<swift::irgen::ProtocolEntry>, swift::ProtocolDecl*, llvm::function_ref<llvm::Value* (unsigned int)> const&) + 273
17 swift                    0x000000010e4fe5e0 swift::irgen::emitArchetypeWitnessTableRef(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::ArchetypeType>, swift::ProtocolDecl*) + 176
18 swift                    0x000000010e4fe4bd swift::irgen::emitAssociatedTypeMetadataRef(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::ArchetypeType>, swift::AssociatedTypeDecl*) + 93
19 swift                    0x000000010e4fe3cc swift::irgen::emitArchetypeTypeMetadataRef(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::ArchetypeType>) + 108
20 swift                    0x000000010e4fe6ee swift::irgen::emitAssociatedTypeWitnessTableRef(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::ArchetypeType>, swift::AssociatedTypeDecl*, llvm::Value*, swift::ProtocolDecl*) + 158
21 swift                    0x000000010e500cba llvm::Value* llvm::function_ref<llvm::Value* (unsigned int)>::callback_fn<swift::irgen::emitArchetypeWitnessTableRef(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::ArchetypeType>, swift::ProtocolDecl*)::$_0>(long, unsigned int) + 442
22 swift                    0x000000010e5d2961 swift::irgen::emitImpliedWitnessTableRef(swift::irgen::IRGenFunction&, llvm::ArrayRef<swift::irgen::ProtocolEntry>, swift::ProtocolDecl*, llvm::function_ref<llvm::Value* (unsigned int)> const&) + 273
23 swift                    0x000000010e4fe5e0 swift::irgen::emitArchetypeWitnessTableRef(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::ArchetypeType>, swift::ProtocolDecl*) + 176
24 swift                    0x000000010e4fe4bd swift::irgen::emitAssociatedTypeMetadataRef(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::ArchetypeType>, swift::AssociatedTypeDecl*) + 93

@tkrajacic
Copy link
Author

Still crashes with the latest snapshot (13th Jan 2017), but with

`Command failed due to signal: Illegal instruction: 4`

@slavapestov
Copy link
Member

Yeah, this still needs the new generic signature minimization algorithm that @DougGregor is going to be working on.

@DougGregor
Copy link
Member

Slightly reduced:

protocol P {
  associatedtype PType
}

public protocol Q {
  associatedtype QType: R
}

public protocol R {
  associatedtype RType
}

func f<T: P>(_: T) where T.PType.RType: Q, T.PType.RType.QType == T.PType {}

@DougGregor
Copy link
Member

I've been looking at this one for a while, and the code itself is ill-formed because it's missing a constraint. Swift 2.x just tolerated it (because of the way it handled "derived" constraints); Swift 3 started relying on well-formed constraints more thoroughly, and the recent refactoring we've done has pushed that reliance earlier in the pipeline.

In my reduced example above, we are missing the constraint `T.PType: R`. Without it, there is no way to name `T.PType.RType`. With that constraint (which corresponds to `Factory.Item: EntityOwned` in the original project – which is also missing and should be added!), the project compiles with Xcode 8.3 and master.

So... the bug here is that we should be producing an error on this code, either because (1) `RType` does not exist on `T.PType` or (if we realize this is what was intended) because (2) `T.PType` does not conform to `R`.

@DougGregor
Copy link
Member

In case my above ramble wasn't clear, the code in question should produce an error. Adding the requirement

Factory.Item: EntityOwned

to class PropertyTableViewAdapter fixes the crash and things seem to work properly.

@DougGregor
Copy link
Member

#10714

@DougGregor
Copy link
Member

GitHub master c063d49

@tkrajacic
Copy link
Author

This is long done

@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 IRGen LLVM IR generation regression swift 3.0
Projects
None yet
Development

No branches or pull requests

5 participants