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-12416] SILGen crash conforming class to Sequence #54855

Closed
dabrahams opened this issue Mar 25, 2020 · 1 comment
Closed

[SR-12416] SILGen crash conforming class to Sequence #54855

dabrahams opened this issue Mar 25, 2020 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@dabrahams
Copy link
Collaborator

Previous ID SR-12416
Radar rdar://problem/62201001
Original Reporter @dabrahams
Type Bug
Status Resolved
Resolution Duplicate
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: a0412af94faefa7bbaddab37ead11c84

duplicates:

  • SR-8814 GenericSignatureBuilder should re-introduce conformance requirements when adding a superclass requirement

Issue Description:

Compile this:

protocol P {
  associatedtype Element
}

protocol Q {  }

class Batcher<S: P> : Sequence where S.Element: Q {
  typealias Element = S.Element
  struct Iterator : IteratorProtocol {
    mutating func next() -> Element? { fatalError() }
  }
  func makeIterator() -> Iterator { fatalError() }
}

It crashes even with the stock swift compiler. In my nightly build which gives better diagnostics, I get:

Assertion failed: (is<T>() && "Invalid accessor called"), function get, file /Users/swiftninjas/s4tf/llvm-project/llvm/include/llvm/ADT/PointerUnion.h, line 195.
Stack dump:
0.  Program arguments: /Library/Developer/Toolchains/swift-tensorflow-DEVELOPMENT-2020-03-07-a.xctoolchain/usr/bin/swift -frontend -interpret x.swift -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -module-name x 
1.  Swift version 5.2-dev (LLVM b3057cffb6, Swift 2cf711d7ae)
2.  While evaluating request SILGenWholeModuleRequest(SIL Generation for module x)
3.  While generating SIL witness table protocol conformance to 'Sequence' (in module 'Swift') for type 'Batcher<S>' (declared at [x.swift:7:1 - line:13:1] RangeText="class Batcher<S: P> : Sequence where S.Element: Q {
  typealias Element = S.Element
  struct Iterator : IteratorProtocol {
    mutating func next() -> Element? { fatalError() }
  }
  func makeIterator() -> Iterator { fatalError() }
")
4.  While generating protocol witness thunk SIL function "@$s1x7BatcherCyqd__GSTAAST19underestimatedCountSivgTW".
 for getter for underestimatedCount (in module 'Swift')
0  swift                    0x00000001130b0dd5 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  swift                    0x00000001130b0015 llvm::sys::RunSignalHandlers() + 85
2  swift                    0x00000001130b13bc SignalHandler(int) + 268
3  libsystem_platform.dylib 0x00007fff72c0242d _sigtramp + 29
4  swift                    0x0000000115913d68 cmark_strbuf__initbuf + 170683
5  libsystem_c.dylib        0x00007fff72ad7a1c abort + 120
6  libsystem_c.dylib        0x00007fff72ad6cd6 err + 0
7  swift                    0x0000000113232bd3 swift::Lowering::SILGenModule::useConformance(swift::ProtocolConformanceRef) (.cold.1) + 35
8  swift                    0x000000010f352ef7 swift::Lowering::SILGenModule::useConformance(swift::ProtocolConformanceRef) + 535
9  swift                    0x000000010f352d8c swift::Lowering::SILGenModule::useConformance(swift::ProtocolConformanceRef) + 172
10 swift                    0x000000010f35350d swift::SILInstructionVisitor<LazyConformanceEmitter, void>::visit(swift::SILInstruction*) + 1101
11 swift                    0x000000010f353073 swift::Lowering::SILGenModule::emitLazyConformancesForFunction(swift::SILFunction*) + 99
12 swift                    0x000000010f3a8e34 swift::Lowering::SILGenModule::emitProtocolWitness(swift::ProtocolConformanceRef, swift::SILLinkage, swift::IsSerialized_t, swift::SILDeclRef, swift::SILDeclRef, swift::Lowering::IsFreeFunctionWitness_t, swift::Witness) + 2980
13 swift                    0x000000010f3ab2fa (anonymous namespace)::SILGenWitnessTable<(anonymous namespace)::SILGenConformance>::addMethodImplementation(swift::SILDeclRef, swift::SILDeclRef, swift::Witness) + 330
14 swift                    0x000000010f3ab174 (anonymous namespace)::SILGenWitnessTable<(anonymous namespace)::SILGenConformance>::addMethod(swift::SILDeclRef) + 500
15 swift                    0x000000010f3aad82 swift::SILWitnessVisitor<(anonymous namespace)::SILGenConformance>::addMethodAndAutoDiffAssociatedMethodsIfRequired(swift::AbstractFunctionDecl*, swift::SILDeclRef::Kind) + 98
16 swift                    0x000000010ff0d746 swift::AbstractStorageDecl::visitExpectedOpaqueAccessors(llvm::function_ref<void (swift::AccessorKind)>) const + 166
17 swift                    0x000000010ff0d68c swift::AbstractStorageDecl::visitOpaqueAccessors(llvm::function_ref<void (swift::AccessorDecl*)>) const + 44
18 swift                    0x000000010f3aab2f swift::SILWitnessVisitor<(anonymous namespace)::SILGenConformance>::visitProtocolDecl(swift::ProtocolDecl*) + 2367
19 swift                    0x000000010f3a8104 swift::Lowering::SILGenModule::getWitnessTable(swift::NormalProtocolConformance*) + 356
20 swift                    0x000000010f3aa01c (anonymous namespace)::SILGenType::emitType() + 1436
21 swift                    0x000000010f3a9a79 swift::Lowering::SILGenModule::visitNominalTypeDecl(swift::NominalTypeDecl*) + 25
22 swift                    0x000000010f2c6593 (anonymous namespace)::SILGenModuleRAII::emitSourceFile(swift::SourceFile*) + 883
23 swift                    0x000000010f2c7554 swift::SILGenWholeModuleRequest::evaluate(swift::Evaluator&, swift::SILGenDescriptor) const + 180
24 swift                    0x000000010f39c491 swift::SimpleRequest<swift::SILGenWholeModuleRequest, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> > (swift::SILGenDescriptor), (swift::CacheKind)0>::evaluateRequest(swift::SILGenWholeModuleRequest const&, swift::Evaluator&) + 33
25 swift                    0x000000010f2caf37 llvm::Expected<swift::SILGenWholeModuleRequest::OutputType> swift::Evaluator::getResultUncached<swift::SILGenWholeModuleRequest>(swift::SILGenWholeModuleRequest const&) + 343
26 swift                    0x000000010f2c76d4 swift::performSILGeneration(swift::ModuleDecl*, swift::Lowering::TypeConverter&, swift::SILOptions const&) + 116
27 swift                    0x000000010efe856b performCompile(swift::CompilerInstance&, swift::CompilerInvocation const&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 8683
28 swift                    0x000000010efe53b8 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 4472
29 swift                    0x000000010ef77ced main + 861
30 libdyld.dylib            0x00007fff72a097fd start + 1
31 libdyld.dylib            0x0000000000000009 start + 18446603338593036301
@beccadax
Copy link
Contributor

@swift-ci create

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

No branches or pull requests

2 participants