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-10128] Compiler crashes when generic type constraint is the associated type of another protocol which the class also conforms to which and has a default implementation #52530
Comments
I cannot reproduce this on 5.1, so I assume it's fixed. |
I'm seeing this with a near-master with asserts:
@rjmccall, does this look familiar? |
I tried this. |
The crash has moved higher up the stack to SIL. This is definitely a bug in the GSB 0. Program arguments: ./bin/swift -frontend -emit-ir -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -
1. Swift version 5.1.1-dev (Swift 4043d43d43)
2. While generating SIL witness table protocol conformance to 'ProtoB' (at <stdin>:3:1) for type 'Foo<T>' (declared at [<stdin>:14:1 - line:14:32] RangeText="class Foo<T: ProtoA>: ProtoB { ")
3. While generating protocol witness thunk SIL function "@$s4main3FooCyqd__GAA6ProtoBA2aEP5stuffSivgTW".
for getter for stuff (at <stdin>:9:9)
0 swift 0x00000001059c5c28 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1 swift 0x00000001059c4b68 llvm::sys::RunSignalHandlers() + 248
2 swift 0x00000001059c6247 SignalHandler(int) + 295
3 libsystem_platform.dylib 0x00007fff67f6ab1d _sigtramp + 29
4 libdyld.dylib 0x00007fff67d5a065 dyldGlobalLockRelease() + 0
5 libsystem_c.dylib 0x00007fff67e40a1c abort + 120
6 libsystem_c.dylib 0x00007fff67e3fcd6 err + 0
7 swift 0x0000000105ad6893 swift::Lowering::SILGenModule::useConformance(swift::ProtocolConformanceRef) (.cold.1) + 35
8 swift 0x0000000101daba57 swift::Lowering::SILGenModule::useConformance(swift::ProtocolConformanceRef) + 535
9 swift 0x0000000101dab8ec swift::Lowering::SILGenModule::useConformance(swift::ProtocolConformanceRef) + 172
10 swift 0x0000000101dac044 swift::SILInstructionVisitor<LazyConformanceEmitter, void>::visit(swift::SILInstruction*) + 1060
11 swift 0x0000000101dabbf8 swift::Lowering::SILGenModule::emitLazyConformancesForFunction(swift::SILFunction*) + 136
12 swift 0x0000000101dfaa8f swift::Lowering::SILGenModule::emitProtocolWitness(swift::ProtocolConformanceRef, swift::SILLinkage, swift::IsSerialized_t, swift::SILDeclRef, swift::SILDeclRef, swift::Lowering::IsFreeFunctionWitness_t, swift::Witness) + 2111
13 swift 0x0000000101dfc87b (anonymous namespace)::SILGenWitnessTable<(anonymous namespace)::SILGenConformance>::addMethodImplementation(swift::SILDeclRef, swift::SILDeclRef, swift::Witness) + 283
14 swift 0x0000000101dfc72a (anonymous namespace)::SILGenWitnessTable<(anonymous namespace)::SILGenConformance>::addMethod(swift::SILDeclRef) + 362
15 swift 0x0000000101dfc5a8 void llvm::function_ref<void (swift::AccessorDecl*)>::callback_fn<swift::SILWitnessVisitor<(anonymous namespace)::SILGenConformance>::visitAbstractStorageDecl(swift::AbstractStorageDecl*)::'lambda'(swift::AccessorDecl*)>(long, swift::AccessorDecl*) + 72
16 swift 0x00000001027f8876 swift::AbstractStorageDecl::visitExpectedOpaqueAccessors(llvm::function_ref<void (swift::AccessorKind)>) const + 166
17 swift 0x00000001027f87bc swift::AbstractStorageDecl::visitOpaqueAccessors(llvm::function_ref<void (swift::AccessorDecl*)>) const + 44
18 swift 0x0000000101dfc33a swift::SILWitnessVisitor<(anonymous namespace)::SILGenConformance>::visitProtocolDecl(swift::ProtocolDecl*) + 1530
19 swift 0x0000000101dfa0e4 swift::Lowering::SILGenModule::getWitnessTable(swift::NormalProtocolConformance*) + 356
20 swift 0x0000000101dfbb85 (anonymous namespace)::SILGenType::emitType() + 1317
21 swift 0x0000000101dfb659 swift::Lowering::SILGenModule::visitNominalTypeDecl(swift::NominalTypeDecl*) + 25
22 swift 0x0000000101d26e13 swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*) + 915
23 swift 0x0000000101d27d52 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::Lowering::TypeConverter&, swift::SILOptions&, swift::FileUnit*) + 322
24 swift 0x0000000101d28131 swift::performSILGeneration(swift::ModuleDecl*, swift::Lowering::TypeConverter&, swift::SILOptions&) + 17
25 swift 0x0000000101a2ae3d performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 8205
26 swift 0x0000000101a27ec8 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3080
27 swift 0x00000001019cd0be main + 734
28 libdyld.dylib 0x00007fff67d692e5 start + 1
29 libdyld.dylib 0x0000000000000006 start + 2552851746 |
Pulling this back since it hasn't been resolved. |
Comment by Frank Langel (JIRA) @glbrntt Hi George, could you advise on the best way of fixing this issue.
Any advise to get this fix quickly would be much appreciated Kind regards Frank |
fll (JIRA User) I only reported the bug so can't help you there I'm afraid! |
Comment by Frank Langel (JIRA) Hi George, thank you for the response. Who would be a good contact/person to talk to drive this forward? Thanks a lot Frank |
fll (JIRA User) We're aware of this as a structural problem with the GSB. It has the propensity to drop certain kinds of requirements if they are not referenced in a certain structural way. In fact, a much smaller reproducer is protocol Requirement {}
extension C : P {}
class C<T> where T : Requirement {}
protocol P {
associatedtype T : Requirement
func f()
}
extension P {
func f() {}
} This is going to sound very strange, but the workaround is to force a data dependency on the requirement that isn't otherwise referenced by the protocol. In my example above, that means the function "f" needs to use "T" in some way. protocol Requirement {}
extension C : P {}
class C<T> where T : Requirement {}
protocol P {
associatedtype T : Requirement
func f(_ : T)
}
extension P {
func f(_ : T) {}
} We are in the process of re-evaluating the algorithms underpinning the GSB and hope we can arrive at a resolution to this issue that will leave us with not just a more correct facility, but a faster one too! |
Environment
Xcode 10.2 beta 4
Additional Detail from JIRA
md5: f46d160b1e3f4181dc3a360dd5fd62d6
duplicates:
is duplicated by:
relates to:
Issue Description:
The compiler crashes with the following code:
Stacktrace:
The text was updated successfully, but these errors were encountered: