Skip to content

LangOptions: Change default for RequirementMachineAbstractSignatures from Verify to Enabled #42111

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

Merged

Conversation

slavapestov
Copy link
Contributor

We've only seen false positives from verification here, and this request
doesn't emit diagnostics.

…from Verify to Enabled

We've only seen false positives from verification here, and this request
doesn't emit diagnostics.
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test macOS

@slavapestov slavapestov merged commit b90d584 into swiftlang:main Apr 1, 2022
@philipturner
Copy link
Contributor

philipturner commented Apr 24, 2022

@slavapestov this PR fixed a major bug impacting Swift for TensorFlow, which had forced me to disable large chunks of the code base (s4tf/s4tf#6). I could have evaded the bug by passing -requirement-machine-abstract-signatures=enabled into the compiler. Instead, I only ever tried -requirement-machine-abstract-signatures=on - not the correct way to enable RQM. Anyway, this PR fixed the bug by forcing RQM abstract signatures to be on by default.

As I investigated it, the stack trace changed from what's in the JIRA report. Before your #41631, the error message printed out a massive map of the generic constraints. The last stack frames were:

6  swift-frontend           0x000000010355f8e8 swift::Type llvm::function_ref<swift::Type (swift::SubstitutableType*)>::callback_fn<swift::rewriting::RequirementMachine::getCanonicalTypeInContext(swift::Type, swift::ArrayRefView<swift::Type, swift::GenericTypeParamType*, swift::GenericTypeParamType* swift::staticCastHelper<swift::GenericTypeParamType>(swift::Type const&), true>) const::$_0::operator()(swift::Type) const::'lambda'(swift::SubstitutableType*)>(long, swift::SubstitutableType*) + 0
7  swift-frontend           0x00000001035b77e4 swift::Type::transformWithPosition(swift::TypePosition, llvm::function_ref<llvm::Optional<swift::Type> (swift::TypeBase*, swift::TypePosition)>) const + 96
8  swift-frontend           0x00000001035b9ed0 swift::Type::transformRec(llvm::function_ref<llvm::Optional<swift::Type> (swift::TypeBase*)>) const + 36
9  swift-frontend           0x000000010355d69c swift::rewriting::RequirementMachine::getCanonicalTypeInContext(swift::Type, swift::ArrayRefView<swift::Type, swift::GenericTypeParamType*, swift::GenericTypeParamType* swift::staticCastHelper<swift::GenericTypeParamType>(swift::Type const&), true>) const + 56

Afterward, the stack trace ended in the following. The change was because of your modification to how -requirement-machine-abstract-signatures=verify is passed into the compiler. The change to KnuthBendix.cpp did not contribute to the change in stack trace.

6  swift-frontend           0x0000000105f13a9c swift::AbstractGenericSignatureRequestGSB::evaluate(swift::Evaluator&, swift::GenericSignatureImpl const*, llvm::SmallVector<swift::GenericTypeParamType*, 2u>, llvm::SmallVector<swift::Requirement, 2u>) const + 0
7  swift-frontend           0x0000000105aa4138 llvm::PointerIntPair<swift::GenericSignature, 3u, swift::OptionSet<swift::GenericSignatureErrorFlags, unsigned int>, llvm::PointerLikeTypeTraits<swift::GenericSignature>, llvm::PointerIntPairInfo<swift::GenericSignature, 3u, llvm::PointerLikeTypeTraits<swift::GenericSignature> > > swift::SimpleRequest<swift::AbstractGenericSignatureRequest, llvm::PointerIntPair<swift::GenericSignature, 3u, swift::OptionSet<swift::GenericSignatureErrorFlags, unsigned int>, llvm::PointerLikeTypeTraits<swift::GenericSignature>, llvm::PointerIntPairInfo<swift::GenericSignature, 3u, llvm::PointerLikeTypeTraits<swift::GenericSignature> > > (swift::GenericSignatureImpl const*, llvm::SmallVector<swift::GenericTypeParamType*, 2u>, llvm::SmallVector<swift::Requirement, 2u>), (swift::RequestFlags)2>::callDerived<0ul, 1ul, 2ul>(swift::Evaluator&, std::__1::integer_sequence<unsigned long, 0ul, 1ul, 2ul>) const + 164
8  swift-frontend           0x0000000105ef2bac llvm::Expected<swift::AbstractGenericSignatureRequest::OutputType> swift::Evaluator::getResultUncached<swift::AbstractGenericSignatureRequest>(swift::AbstractGenericSignatureRequest const&) + 252
9  swift-frontend           0x0000000105ef28f0 llvm::Expected<swift::AbstractGenericSignatureRequest::OutputType> swift::Evaluator::getResultCached<swift::AbstractGenericSignatureRequest, (void*)0>(swift::AbstractGenericSignatureRequest const&) + 1356
10 swift-frontend           0x0000000105ef0a88 swift::AbstractGenericSignatureRequest::OutputType swift::evaluateOrDefault<swift::AbstractGenericSignatureRequest>(swift::Evaluator&, swift::AbstractGenericSignatureRequest, swift::AbstractGenericSignatureRequest::OutputType) + 44

Also, the error message was much more comprehensible. It said that RequirementMachine and GenericSignatureBuilder disagreed on something.

RequirementMachine generic signature minimization is broken:
RequirementMachine says:      <τ_0_0, τ_0_1, τ_0_2 where τ_0_0 : RecurrentLayerCell, τ_0_0 == τ_0_1>
GenericSignatureBuilder says: <τ_0_0, τ_0_1, τ_0_2 where τ_0_0 : RecurrentLayerCell>

SR-15884 was a very peculiar edge case that involved @_spi, Reflection, and AutoDiff. Could you give me the gist of what went on here? Have you seen something resembling the conflict of constraints in SR-15884's first stack trace before? If there is a regression test for that, I want to reference when I contribute an AutoDiff compiler crasher test for SR-15884.

P.S. I'm reading your research paper right now, so I might understand what happened better afterward. I'm trying to fix SR-14228, another AutoDiff crasher, and I can't understand how to solve the bug without first knowing how RequirementMachine works.

@slavapestov
Copy link
Contributor Author

@philipturner Does RecurrentLayerCell inherit from CaseIterable? The purpose of verify mode was to catch requirement machine bugs -- a change in the minimized signature indicates a possible ABI break. However it sometimes caught GSB bugs as well, in particular the GSB would often drop requirements with signatures involving CaseIterable because it was unable to reason about the 'Self.Element == Self' requirement in the CaseIterable protocol.

@philipturner
Copy link
Contributor

philipturner commented Apr 25, 2022

Here is the full reproducer. There is no CaseIterable, but it synthesizes something possibly similar: KeyPathIterable.

import _Differentiation
@_spi(Reflection) import Swift

struct RNNCellInput<Input>: Differentiable {}
struct RNNCellOutput<Output>: Differentiable {}

protocol Layer: Differentiable {
  associatedtype Input
  associatedtype Output: Differentiable
  
  @differentiable(reverse)
  func callAsFunction(_ input: Input) -> Output
}

public protocol KeyPathIterable {
  associatedtype AllKeyPaths: Sequence
    where AllKeyPaths.Element == PartialKeyPath<Self>
}

protocol RecurrentLayerCell: Layer, KeyPathIterable
where
  Input == RNNCellInput<TimeStepInput>,
  Output == RNNCellOutput<TimeStepOutput>
{
  associatedtype TimeStepInput
  associatedtype TimeStepOutput: Differentiable
}

struct RecurrentLayer<Cell: RecurrentLayerCell>: Layer {
  typealias Input = Cell.TimeStepInput
  typealias Output = Cell.TimeStepOutput

  var cell: Cell

  @differentiable(reverse)
  func callAsFunction(_ inputs: Cell.TimeStepInput) -> Cell.TimeStepOutput {
    return self(inputs)
  }
}

Is it possible to narrow down this reproducer further, to use CaseIterable instead of KeyPathIterable, or another combination that triggers the same crash?

@philipturner
Copy link
Contributor

philipturner commented Apr 26, 2022

It's a CaseIterable crash. I just made this new reproducer, which crashes in the same place.

Reproducer
import _Differentiation

struct RNNCellInput<Input>: Differentiable {}
struct RNNCellOutput<Output>: Differentiable {}

protocol Layer: Differentiable {
  associatedtype Input
  associatedtype Output: Differentiable
  
  @differentiable(reverse)
  func callAsFunction(_ input: Input) -> Output
}

protocol RecurrentLayerCell: Layer, CaseIterable
where
  Input == RNNCellInput<TimeStepInput>,
  Output == RNNCellOutput<TimeStepOutput>
{
  associatedtype TimeStepInput
  associatedtype TimeStepOutput: Differentiable
}

struct RecurrentLayer<Cell: RecurrentLayerCell>: Layer {
  typealias Input = Cell.TimeStepInput
  typealias Output = Cell.TimeStepOutput

  var cell: Cell

  @differentiable(reverse)
  func callAsFunction(_ inputs: Cell.TimeStepInput) -> Cell.TimeStepOutput {
    return self(inputs)
  }
}

Mentioning #58149

@slavapestov
Copy link
Contributor Author

What's the crash?

@philipturner
Copy link
Contributor

I tested it on the March 30 toolchain.

Crash log
RequirementMachine generic signature minimization is broken:
RequirementMachine says:      <τ_0_0, τ_0_1, τ_0_2 where τ_0_0 : RecurrentLayerCell, τ_0_0 == τ_0_1>
GenericSignatureBuilder says: <τ_0_0, τ_0_1, τ_0_2 where τ_0_0 : RecurrentLayerCell>
Stack dump:
0.	Program arguments: /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2022-03-30-a.xctoolchain/usr/bin/swift-frontend -frontend -interpret script.swift -Xllvm -aarch64-use-tbi -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk -color-diagnostics -new-driver-path /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2022-03-30-a.xctoolchain/usr/bin/swift-driver -empty-abi-descriptor -resource-dir /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2022-03-30-a.xctoolchain/usr/lib/swift -module-name script -target-sdk-version 12.3
1.	Apple Swift version 5.7-dev (LLVM 387a3789411db1a, Swift 128d6e1cd41ef27)
2.	Compiling with the current language version
3.	While evaluating request ASTLoweringRequest(Lowering AST to SIL for module script)
4.	While generating SIL witness table protocol conformance to 'Layer' (at script.swift:7:1) for type 'RecurrentLayer<Cell>' (declared at [script.swift:29:1 - line:39:1] RangeText="struct RecurrentLayer<Cell: RecurrentLayerCell>: Layer {
  typealias Input = Cell.TimeStepInput
  typealias Output = Cell.TimeStepOutput

  var cell: Cell

  @differentiable(reverse)
  func callAsFunction(_ inputs: Cell.TimeStepInput) -> Cell.TimeStepOutput {
    return self(inputs)
  }
")
5.	While generating protocol witness thunk SIL function "@AD__$s6script14RecurrentLayerVyxGAA0C0A2aEP14callAsFunctiony6OutputQz5InputQzFTW_jvp_US".
 for 'callAsFunction(_:)' (at script.swift:36:3)
6.	While evaluating request AbstractGenericSignatureRequest(NULL, {τ_0_0, τ_0_1, τ_0_2}, {τ_0_0 : RecurrentLayerCell, τ_0_1 == τ_0_0})
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  swift-frontend           0x00000001054eab90 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x00000001054e9df0 llvm::sys::RunSignalHandlers() + 128
2  swift-frontend           0x00000001054eb1f4 SignalHandler(int) + 304
3  libsystem_platform.dylib 0x000000019cd194c4 _sigtramp + 56
4  libsystem_pthread.dylib  0x000000019cd01ee0 pthread_kill + 288
5  libsystem_c.dylib        0x000000019cc3c340 abort + 168
6  swift-frontend           0x00000001021531b4 swift::AbstractGenericSignatureRequestGSB::evaluate(swift::Evaluator&, swift::GenericSignatureImpl const*, llvm::SmallVector<swift::GenericTypeParamType*, 2u>, llvm::SmallVector<swift::Requirement, 2u>) const + 0
7  swift-frontend           0x0000000101ce3fcc llvm::PointerIntPair<swift::GenericSignature, 3u, swift::OptionSet<swift::GenericSignatureErrorFlags, unsigned int>, llvm::PointerLikeTypeTraits<swift::GenericSignature>, llvm::PointerIntPairInfo<swift::GenericSignature, 3u, llvm::PointerLikeTypeTraits<swift::GenericSignature> > > swift::SimpleRequest<swift::AbstractGenericSignatureRequest, llvm::PointerIntPair<swift::GenericSignature, 3u, swift::OptionSet<swift::GenericSignatureErrorFlags, unsigned int>, llvm::PointerLikeTypeTraits<swift::GenericSignature>, llvm::PointerIntPairInfo<swift::GenericSignature, 3u, llvm::PointerLikeTypeTraits<swift::GenericSignature> > > (swift::GenericSignatureImpl const*, llvm::SmallVector<swift::GenericTypeParamType*, 2u>, llvm::SmallVector<swift::Requirement, 2u>), (swift::RequestFlags)2>::callDerived<0ul, 1ul, 2ul>(swift::Evaluator&, std::__1::integer_sequence<unsigned long, 0ul, 1ul, 2ul>) const + 164
8  swift-frontend           0x00000001021322c4 llvm::Expected<swift::AbstractGenericSignatureRequest::OutputType> swift::Evaluator::getResultUncached<swift::AbstractGenericSignatureRequest>(swift::AbstractGenericSignatureRequest const&) + 252
9  swift-frontend           0x0000000102132008 llvm::Expected<swift::AbstractGenericSignatureRequest::OutputType> swift::Evaluator::getResultCached<swift::AbstractGenericSignatureRequest, (void*)0>(swift::AbstractGenericSignatureRequest const&) + 1356
10 swift-frontend           0x00000001021301a0 swift::AbstractGenericSignatureRequest::OutputType swift::evaluateOrDefault<swift::AbstractGenericSignatureRequest>(swift::Evaluator&, swift::AbstractGenericSignatureRequest, swift::AbstractGenericSignatureRequest::OutputType) + 44
11 swift-frontend           0x0000000102130600 swift::buildGenericSignature(swift::ASTContext&, swift::GenericSignature, llvm::SmallVector<swift::GenericTypeParamType*, 2u>, llvm::SmallVector<swift::Requirement, 2u>) + 152
12 swift-frontend           0x00000001010b054c swift::Lowering::AbstractionPattern::getSubstFunctionTypePattern(swift::CanTypeWrapper<swift::AnyFunctionType>, swift::Lowering::TypeConverter&, swift::Lowering::AbstractionPattern, swift::CanType) const + 448
13 swift-frontend           0x00000001010deaec getSILFunctionType(swift::Lowering::TypeConverter&, swift::TypeExpansionContext, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::SILExtInfoBuilder, (anonymous namespace)::Conventions const&, swift::ForeignInfo const&, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SubstitutionMap>, swift::ProtocolConformanceRef, llvm::Optional<llvm::SmallBitVector>) + 1436
14 swift-frontend           0x00000001010de4e4 getNativeSILFunctionType(swift::Lowering::TypeConverter&, swift::TypeExpansionContext, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::SILExtInfoBuilder, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SubstitutionMap>, swift::ProtocolConformanceRef, llvm::Optional<llvm::SmallBitVector>)::$_19::operator()((anonymous namespace)::Conventions const&) const + 316
15 swift-frontend           0x00000001010d6a40 getNativeSILFunctionType(swift::Lowering::TypeConverter&, swift::TypeExpansionContext, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::SILExtInfoBuilder, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SubstitutionMap>, swift::ProtocolConformanceRef, llvm::Optional<llvm::SmallBitVector>) + 504
16 swift-frontend           0x00000001010d67fc swift::getNativeSILFunctionType(swift::Lowering::TypeConverter&, swift::TypeExpansionContext, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::SILExtInfo, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SubstitutionMap>, swift::ProtocolConformanceRef) + 104
17 swift-frontend           0x0000000101164790 swift::Lowering::TypeConverter::computeLoweredRValueType(swift::TypeExpansionContext, swift::Lowering::AbstractionPattern, swift::CanType)::LoweredRValueTypeVisitor::visitAnyFunctionType(swift::CanTypeWrapper<swift::AnyFunctionType>) + 736
18 swift-frontend           0x0000000101154400 swift::CanTypeVisitor<swift::Lowering::TypeConverter::computeLoweredRValueType(swift::TypeExpansionContext, swift::Lowering::AbstractionPattern, swift::CanType)::LoweredRValueTypeVisitor, swift::CanType>::visit(swift::CanType) + 432
19 swift-frontend           0x0000000101152d9c swift::Lowering::TypeConverter::getTypeLowering(swift::Lowering::AbstractionPattern, swift::Type, swift::TypeExpansionContext) + 592
20 swift-frontend           0x00000001010e0470 (anonymous namespace)::DestructureResults::destructure(swift::Lowering::AbstractionPattern, swift::CanType) + 248
21 swift-frontend           0x00000001010e03fc (anonymous namespace)::DestructureResults::destructure(swift::Lowering::AbstractionPattern, swift::CanType) + 132
22 swift-frontend           0x00000001010df21c getSILFunctionType(swift::Lowering::TypeConverter&, swift::TypeExpansionContext, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::SILExtInfoBuilder, (anonymous namespace)::Conventions const&, swift::ForeignInfo const&, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SubstitutionMap>, swift::ProtocolConformanceRef, llvm::Optional<llvm::SmallBitVector>) + 3276
23 swift-frontend           0x00000001010de4e4 getNativeSILFunctionType(swift::Lowering::TypeConverter&, swift::TypeExpansionContext, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::SILExtInfoBuilder, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SubstitutionMap>, swift::ProtocolConformanceRef, llvm::Optional<llvm::SmallBitVector>)::$_19::operator()((anonymous namespace)::Conventions const&) const + 316
24 swift-frontend           0x00000001010d6a40 getNativeSILFunctionType(swift::Lowering::TypeConverter&, swift::TypeExpansionContext, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::SILExtInfoBuilder, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SubstitutionMap>, swift::ProtocolConformanceRef, llvm::Optional<llvm::SmallBitVector>) + 504
25 swift-frontend           0x00000001010d9230 getUncachedSILFunctionTypeForConstant(swift::Lowering::TypeConverter&, swift::TypeExpansionContext, swift::SILDeclRef, swift::Lowering::TypeConverter::LoweredFormalTypes) + 1920
26 swift-frontend           0x00000001010d9b60 swift::Lowering::TypeConverter::getConstantInfo(swift::TypeExpansionContext, swift::SILDeclRef) + 216
27 swift-frontend           0x00000001015e9ec8 swift::Lowering::SILGenFunction::emitProtocolWitness(swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::SILDeclRef, swift::SubstitutionMap, swift::SILDeclRef, swift::SubstitutionMap, swift::Lowering::IsFreeFunctionWitness_t, bool) + 680
28 swift-frontend           0x0000000101601cb8 swift::Lowering::SILGenModule::emitProtocolWitness(swift::ProtocolConformanceRef, swift::SILLinkage, swift::IsSerialized_t, swift::SILDeclRef, swift::SILDeclRef, swift::Lowering::IsFreeFunctionWitness_t, swift::Witness) + 2452
29 swift-frontend           0x0000000101603ea8 (anonymous namespace)::SILGenWitnessTable<(anonymous namespace)::SILGenConformance>::addMethodImplementation(swift::SILDeclRef, swift::SILDeclRef, swift::Witness) + 448
30 swift-frontend           0x0000000101603adc (anonymous namespace)::SILGenWitnessTable<(anonymous namespace)::SILGenConformance>::addMethod(swift::SILDeclRef) + 792
31 swift-frontend           0x0000000101603c34 swift::SILWitnessVisitor<(anonymous namespace)::SILGenConformance>::addAutoDiffDerivativeMethodsIfRequired(swift::AbstractFunctionDecl*, swift::SILDeclRef::Kind) + 268
32 swift-frontend           0x00000001016035ec swift::SILWitnessVisitor<(anonymous namespace)::SILGenConformance>::visitProtocolDecl(swift::ProtocolDecl*) + 1952
33 swift-frontend           0x00000001016011c0 swift::Lowering::SILGenModule::getWitnessTable(swift::NormalProtocolConformance*) + 316
34 swift-frontend           0x0000000101602c3c (anonymous namespace)::SILGenType::emitType() + 1724
35 swift-frontend           0x0000000101602574 swift::Lowering::SILGenModule::visitNominalTypeDecl(swift::NominalTypeDecl*) + 24
36 swift-frontend           0x000000010154b1c0 swift::ASTLoweringRequest::evaluate(swift::Evaluator&, swift::ASTLoweringDescriptor) const + 1792
37 swift-frontend           0x00000001015f6478 swift::SimpleRequest<swift::ASTLoweringRequest, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> > (swift::ASTLoweringDescriptor), (swift::RequestFlags)9>::evaluateRequest(swift::ASTLoweringRequest const&, swift::Evaluator&) + 156
38 swift-frontend           0x000000010154f180 llvm::Expected<swift::ASTLoweringRequest::OutputType> swift::Evaluator::getResultUncached<swift::ASTLoweringRequest>(swift::ASTLoweringRequest const&) + 408
39 swift-frontend           0x000000010154bcf4 swift::performASTLowering(swift::ModuleDecl*, swift::Lowering::TypeConverter&, swift::SILOptions const&) + 144
40 swift-frontend           0x0000000101025a28 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 992
41 swift-frontend           0x0000000101030ba0 withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) + 160
42 swift-frontend           0x00000001010274ec swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2940
43 swift-frontend           0x0000000100f41a50 swift::mainEntry(int, char const**) + 3748
44 dyld                     0x000000010ddb9088 start + 516
zsh: abort      swift script.swift

That's the same as when it was RequirementMachineAbstractSignatures=Verify. Should I still add a regression test to the AutoDiff compiler crashers, or should I just close #58149?

@slavapestov
Copy link
Contributor Author

This is a bug in the GenericSignatureBuilder which is now disabled, and 'verify' mode is no longer on by default since we've finished qualifying the requirement machine. Please try with a newer developer snapshot.

@philipturner
Copy link
Contributor

philipturner commented Apr 26, 2022

The newer (April 4) snapshot had no crash because it was on Enabled. I tried that toolchain first, then had to try again with the March 30 toolchain to reproduce the crash.

The February 25 toolchain, which was before #41631, also has the oldest crash signature:

Crash log
Invalid type parameter in getCanonicalTypeInContext()
Original type: τ_0_1.TangentVector
Simplified term: τ_0_1.[Differentiable:TangentVector]
Longest valid prefix: τ_0_1
Prefix type: τ_0_1

Requirement machine for <τ_0_0, τ_0_1, τ_0_2 where τ_0_0 : RecurrentLayerCell>
Rewrite system: {
- [RecurrentLayerCell].[RecurrentLayerCell] => [RecurrentLayerCell] [permanent]
- [RecurrentLayerCell].TimeStepInput => [RecurrentLayerCell:TimeStepInput] [permanent]
- [RecurrentLayerCell].TimeStepOutput => [RecurrentLayerCell:TimeStepOutput] [permanent]
- [RecurrentLayerCell].Input => [RecurrentLayerCell:Input] [permanent]
- [RecurrentLayerCell].Output => [RecurrentLayerCell:Output] [permanent]
- [RecurrentLayerCell].TangentVector => [RecurrentLayerCell:TangentVector] [permanent]
- [RecurrentLayerCell].AllCases => [RecurrentLayerCell:AllCases] [permanent]
- [CaseIterable].[CaseIterable] => [CaseIterable] [permanent]
- [CaseIterable].AllCases => [CaseIterable:AllCases] [permanent]
- [Layer].[Layer] => [Layer] [permanent]
- [Layer].Input => [Layer:Input] [permanent]
- [Layer].Output => [Layer:Output] [permanent]
- [Layer].TangentVector => [Layer:TangentVector] [permanent]
- [Differentiable].[Differentiable] => [Differentiable] [permanent]
- [Differentiable].TangentVector => [Differentiable:TangentVector] [permanent]
- [Collection].[Collection] => [Collection] [permanent]
- [Collection].Element => [Collection:Element] [permanent]
- [Collection].Index => [Collection:Index] [permanent]
- [Collection].Iterator => [Collection:Iterator] [permanent]
- [Collection].SubSequence => [Collection:SubSequence] [permanent]
- [Collection].Indices => [Collection:Indices] [permanent]
- [AdditiveArithmetic].[AdditiveArithmetic] => [AdditiveArithmetic] [permanent]
- [Sequence].[Sequence] => [Sequence] [permanent]
- [Sequence].Element => [Sequence:Element] [permanent]
- [Sequence].Iterator => [Sequence:Iterator] [permanent]
- [Comparable].[Comparable] => [Comparable] [permanent]
- [Equatable].[Equatable] => [Equatable] [permanent]
- [IteratorProtocol].[IteratorProtocol] => [IteratorProtocol] [permanent]
- [IteratorProtocol].Element => [IteratorProtocol:Element] [permanent]
- [RecurrentLayerCell].[CaseIterable] => [RecurrentLayerCell] [explicit]
- [RecurrentLayerCell].[Layer] => [RecurrentLayerCell] [explicit]
- [RecurrentLayerCell:Input].[concrete: RNNCellInput<[RecurrentLayerCell:TimeStepInput]>] => [RecurrentLayerCell:Input] [explicit]
- [RecurrentLayerCell:Output].[concrete: RNNCellOutput<[RecurrentLayerCell:TimeStepOutput]>] => [RecurrentLayerCell:Output] [explicit]
- [RecurrentLayerCell:TimeStepOutput].[Differentiable] => [RecurrentLayerCell:TimeStepOutput] [explicit]
- [CaseIterable:AllCases].[Sequence:Element] => [CaseIterable] [explicit]
- [CaseIterable:AllCases].[Collection] => [CaseIterable:AllCases] [explicit]
- [Layer].[Differentiable] => [Layer] [explicit]
- [Layer:Output].[Differentiable] => [Layer:Output] [explicit]
- [Differentiable:TangentVector].[AdditiveArithmetic] => [Differentiable:TangentVector] [explicit]
- [Differentiable:TangentVector].[Differentiable] => [Differentiable:TangentVector] [explicit]
- [Differentiable:TangentVector].[Differentiable:TangentVector] => [Differentiable:TangentVector] [explicit]
- [Collection].[Sequence] => [Collection] [explicit]
- [Collection:SubSequence].[Sequence:Element] => [Collection:Element] [explicit]
- [Collection:Index].[Comparable] => [Collection:Index] [explicit]
- [Collection:Indices].[Sequence:Element] => [Collection:Index] [explicit]
- [Collection:Indices].[Collection] => [Collection:Indices] [explicit]
- [Collection:Indices].[Collection:SubSequence] => [Collection:Indices] [explicit]
- [Collection:SubSequence].[Collection] => [Collection:SubSequence] [explicit]
- [Collection:SubSequence].[Collection:SubSequence] => [Collection:SubSequence] [explicit]
- [Collection:Indices].[Collection:Index] => [Collection:Index] [explicit]
- [Collection:SubSequence].[Collection:Index] => [Collection:Index] [explicit]
- [Collection].IndexDistance.[concrete: Int] => [Collection].IndexDistance [explicit]
- [Collection]._Element => [Collection:Element] [explicit]
- [AdditiveArithmetic].[Equatable] => [AdditiveArithmetic] [explicit]
- [Sequence:Iterator].[IteratorProtocol:Element] => [Sequence:Element] [explicit]
- [Sequence:Iterator].[IteratorProtocol] => [Sequence:Iterator] [explicit]
- [Sequence].Generator => [Sequence:Iterator] [explicit]
- [Comparable].[Equatable] => [Comparable] [explicit]
- τ_0_0.[RecurrentLayerCell] => τ_0_0 [explicit]
- [RecurrentLayerCell].[RecurrentLayerCell:TimeStepInput] => [RecurrentLayerCell:TimeStepInput]
- [RecurrentLayerCell].[RecurrentLayerCell:TimeStepOutput] => [RecurrentLayerCell:TimeStepOutput]
- [RecurrentLayerCell].[RecurrentLayerCell:Input] => [RecurrentLayerCell:Input]
- [RecurrentLayerCell].[RecurrentLayerCell:Output] => [RecurrentLayerCell:Output]
- [RecurrentLayerCell].[RecurrentLayerCell:TangentVector] => [RecurrentLayerCell:TangentVector]
- [RecurrentLayerCell].[RecurrentLayerCell:AllCases] => [RecurrentLayerCell:AllCases]
- [CaseIterable].[CaseIterable:AllCases] => [CaseIterable:AllCases]
- [Layer].[Layer:Input] => [Layer:Input]
- [Layer].[Layer:Output] => [Layer:Output]
- [Layer].[Layer:TangentVector] => [Layer:TangentVector]
- [Differentiable].[Differentiable:TangentVector] => [Differentiable:TangentVector]
- [Collection].[Collection:Element] => [Collection:Element]
- [Collection].[Collection:Index] => [Collection:Index]
- [Collection].[Collection:Iterator] => [Collection:Iterator]
- [Collection].[Collection:SubSequence] => [Collection:SubSequence]
- [Collection].[Collection:Indices] => [Collection:Indices]
- [Sequence].[Sequence:Element] => [Sequence:Element]
- [Sequence].[Sequence:Iterator] => [Sequence:Iterator]
- [IteratorProtocol].[IteratorProtocol:Element] => [IteratorProtocol:Element]
- [RecurrentLayerCell].[CaseIterable:AllCases] => [RecurrentLayerCell:AllCases]
- [RecurrentLayerCell].[Layer:Input] => [RecurrentLayerCell:Input]
- [RecurrentLayerCell].[Layer:Output] => [RecurrentLayerCell:Output]
- [RecurrentLayerCell].[Layer:TangentVector] => [RecurrentLayerCell:TangentVector]
- [RecurrentLayerCell].[Differentiable] => [RecurrentLayerCell]
- [RecurrentLayerCell:TimeStepOutput].TangentVector => [RecurrentLayerCell:TimeStepOutput].[Differentiable:TangentVector]
- [CaseIterable:AllCases].Element => [CaseIterable:AllCases].[Collection:Element] [lhs↓] [rhs↓]
- [CaseIterable:AllCases].Index => [CaseIterable:AllCases].[Collection:Index]
- [CaseIterable:AllCases].Iterator => [CaseIterable:AllCases].[Collection:Iterator]
- [CaseIterable:AllCases].SubSequence => [CaseIterable:AllCases].[Collection:SubSequence]
- [CaseIterable:AllCases].Indices => [CaseIterable:AllCases].[Collection:Indices]
- [CaseIterable:AllCases].[Sequence] => [CaseIterable:AllCases]
- [CaseIterable:AllCases].IndexDistance.[concrete: Int] => [CaseIterable:AllCases].IndexDistance
- [CaseIterable:AllCases]._Element => [CaseIterable:AllCases].[Collection:Element] [lhs↓] [rhs↓]
- [Layer].[Differentiable:TangentVector] => [Layer:TangentVector]
- [Layer:Output].TangentVector => [Layer:Output].[Differentiable:TangentVector]
- [Differentiable:TangentVector].[Equatable] => [Differentiable:TangentVector]
- [Differentiable:TangentVector].TangentVector => [Differentiable:TangentVector]
- [Collection].[Sequence:Element] => [Collection:Element]
- [Collection].[Sequence:Iterator] => [Collection:Iterator]
- [Collection].Generator => [Collection:Iterator]
- [Collection:Index].[Equatable] => [Collection:Index]
- [Collection:Indices].Element => [Collection:Indices].[Collection:Element] [lhs↓] [rhs↓]
- [Collection:Indices].Index => [Collection:Index]
- [Collection:Indices].Iterator => [Collection:Indices].[Collection:Iterator]
- [Collection:Indices].SubSequence => [Collection:Indices]
- [Collection:Indices].Indices => [Collection:Indices].[Collection:Indices]
- [Collection:Indices].[Sequence] => [Collection:Indices]
- [Collection:Indices].IndexDistance.[concrete: Int] => [Collection:Indices].IndexDistance
- [Collection:Indices]._Element => [Collection:Indices].[Collection:Element] [lhs↓] [rhs↓]
- [Collection:Indices].[Collection:Element] => [Collection:Index]
- [Collection:SubSequence].Element => [Collection:SubSequence].[Collection:Element] [lhs↓] [rhs↓]
- [Collection:SubSequence].Index => [Collection:Index]
- [Collection:SubSequence].Iterator => [Collection:SubSequence].[Collection:Iterator]
- [Collection:SubSequence].SubSequence => [Collection:SubSequence]
- [Collection:SubSequence].Indices => [Collection:SubSequence].[Collection:Indices]
- [Collection:SubSequence].[Sequence] => [Collection:SubSequence]
- [Collection:SubSequence].IndexDistance.[concrete: Int] => [Collection:SubSequence].IndexDistance
- [Collection:SubSequence]._Element => [Collection:SubSequence].[Collection:Element] [lhs↓] [rhs↓]
- [Collection:SubSequence].[Collection:Element] => [Collection:Element]
- [Sequence:Iterator].Element => [Sequence:Element]
- τ_0_0.TimeStepInput => τ_0_0.[RecurrentLayerCell:TimeStepInput]
- τ_0_0.TimeStepOutput => τ_0_0.[RecurrentLayerCell:TimeStepOutput]
- τ_0_0.Input => τ_0_0.[RecurrentLayerCell:Input]
- τ_0_0.Output => τ_0_0.[RecurrentLayerCell:Output]
- τ_0_0.TangentVector => τ_0_0.[RecurrentLayerCell:TangentVector]
- τ_0_0.AllCases => τ_0_0.[RecurrentLayerCell:AllCases]
- τ_0_0.[CaseIterable] => τ_0_0
- τ_0_0.[Layer] => τ_0_0
- [Collection:Indices].Element => [Collection:Index]
- [Collection:Indices]._Element => [Collection:Index]
- [Collection:SubSequence].Element => [Collection:Element]
- [Collection:SubSequence]._Element => [Collection:Element]
- [RecurrentLayerCell].[Differentiable:TangentVector] => [RecurrentLayerCell:TangentVector]
- [CaseIterable:AllCases].[Collection:Element] => [CaseIterable]
- [CaseIterable:AllCases].[Sequence:Iterator] => [CaseIterable:AllCases].[Collection:Iterator]
- [CaseIterable:AllCases].Generator => [CaseIterable:AllCases].[Collection:Iterator]
- [Collection:Indices].[Sequence:Iterator] => [Collection:Indices].[Collection:Iterator]
- [Collection:Indices].Generator => [Collection:Indices].[Collection:Iterator]
- [Collection:SubSequence].[Sequence:Iterator] => [Collection:SubSequence].[Collection:Iterator]
- [Collection:SubSequence].Generator => [Collection:SubSequence].[Collection:Iterator]
- τ_0_0.[CaseIterable:AllCases] => τ_0_0.[RecurrentLayerCell:AllCases]
- τ_0_0.[Layer:Input] => τ_0_0.[RecurrentLayerCell:Input]
- τ_0_0.[Layer:Output] => τ_0_0.[RecurrentLayerCell:Output]
- τ_0_0.[Layer:TangentVector] => τ_0_0.[RecurrentLayerCell:TangentVector]
- τ_0_0.[Differentiable] => τ_0_0
- [RecurrentLayerCell:Input].[concrete: RNNCellInput<[RecurrentLayerCell].[RecurrentLayerCell:TimeStepInput]>] => [RecurrentLayerCell:Input] [subst↓]
- [RecurrentLayerCell:Output].[concrete: RNNCellOutput<[RecurrentLayerCell].[RecurrentLayerCell:TimeStepOutput]>] => [RecurrentLayerCell:Output] [subst↓]
- [RecurrentLayerCell:AllCases].[Sequence:Element] => [RecurrentLayerCell]
- [RecurrentLayerCell:AllCases].[Collection] => [RecurrentLayerCell:AllCases]
- [RecurrentLayerCell:AllCases].Element => [RecurrentLayerCell:AllCases].[Collection:Element] [lhs↓] [rhs↓]
- [RecurrentLayerCell:AllCases].Index => [RecurrentLayerCell:AllCases].[Collection:Index]
- [RecurrentLayerCell:AllCases].Iterator => [RecurrentLayerCell:AllCases].[Collection:Iterator]
- [RecurrentLayerCell:AllCases].SubSequence => [RecurrentLayerCell:AllCases].[Collection:SubSequence]
- [RecurrentLayerCell:AllCases].Indices => [RecurrentLayerCell:AllCases].[Collection:Indices]
- [RecurrentLayerCell:AllCases].[Sequence] => [RecurrentLayerCell:AllCases]
- [RecurrentLayerCell:AllCases].IndexDistance.[concrete: Int] => [RecurrentLayerCell:AllCases].IndexDistance
- [RecurrentLayerCell:AllCases]._Element => [RecurrentLayerCell:AllCases].[Collection:Element] [lhs↓] [rhs↓]
- [RecurrentLayerCell:Output].[Differentiable] => [RecurrentLayerCell:Output]
- [RecurrentLayerCell:Output].TangentVector => [RecurrentLayerCell:Output].[Differentiable:TangentVector]
- [Layer:TangentVector].[AdditiveArithmetic] => [Layer:TangentVector]
- [Layer:TangentVector].[Differentiable] => [Layer:TangentVector]
- [Layer:TangentVector].[Differentiable:TangentVector] => [Layer:TangentVector]
- [Layer:TangentVector].[Equatable] => [Layer:TangentVector]
- [Layer:TangentVector].TangentVector => [Layer:TangentVector]
- [Collection:Iterator].[IteratorProtocol:Element] => [Collection:Element]
- [Collection:Iterator].[IteratorProtocol] => [Collection:Iterator]
- [Collection:Iterator].Element => [Collection:Element]
- τ_0_0.[Differentiable:TangentVector] => τ_0_0.[RecurrentLayerCell:TangentVector]
- [CaseIterable:AllCases].Element => [CaseIterable]
- [CaseIterable:AllCases]._Element => [CaseIterable]
- [RecurrentLayerCell:AllCases].[Collection:Element] => [RecurrentLayerCell]
- [RecurrentLayerCell:AllCases].[Sequence:Iterator] => [RecurrentLayerCell:AllCases].[Collection:Iterator]
- [RecurrentLayerCell:AllCases].Generator => [RecurrentLayerCell:AllCases].[Collection:Iterator]
- [RecurrentLayerCell:TangentVector].[AdditiveArithmetic] => [RecurrentLayerCell:TangentVector]
- [RecurrentLayerCell:TangentVector].[Differentiable] => [RecurrentLayerCell:TangentVector]
- [RecurrentLayerCell:TangentVector].[Differentiable:TangentVector] => [RecurrentLayerCell:TangentVector]
- [RecurrentLayerCell:TangentVector].[Equatable] => [RecurrentLayerCell:TangentVector]
- [RecurrentLayerCell:TangentVector].TangentVector => [RecurrentLayerCell:TangentVector]
- [RecurrentLayerCell:AllCases].Element => [RecurrentLayerCell]
- [RecurrentLayerCell:AllCases]._Element => [RecurrentLayerCell]
- [RecurrentLayerCell:Output].[concrete: RNNCellOutput<[RecurrentLayerCell:TimeStepOutput]> : Differentiable] => [RecurrentLayerCell:Output]
- [RecurrentLayerCell:Output].[Differentiable:TangentVector].[concrete: RNNCellOutput<[RecurrentLayerCell:TimeStepOutput]>.TangentVector] => [RecurrentLayerCell:Output].[Differentiable:TangentVector]
- [RecurrentLayerCell:Output].[concrete: RNNCellOutput<[RecurrentLayerCell].[RecurrentLayerCell:TimeStepOutput]> : Differentiable] => [RecurrentLayerCell:Output] [subst↓]
- [RecurrentLayerCell:Output].[Differentiable:TangentVector].[concrete: RNNCellOutput<[RecurrentLayerCell].[RecurrentLayerCell:TimeStepOutput]>.TangentVector] => [RecurrentLayerCell:Output].[Differentiable:TangentVector] [subst↓]
- [RecurrentLayerCell:Output].[Differentiable:TangentVector].[concrete: RNNCellOutput<[RecurrentLayerCell:TimeStepOutput]>.TangentVector : AdditiveArithmetic] => [RecurrentLayerCell:Output].[Differentiable:TangentVector]
- [RecurrentLayerCell:Output].[Differentiable:TangentVector].[concrete: RNNCellOutput<[RecurrentLayerCell:TimeStepOutput]>.TangentVector : Differentiable] => [RecurrentLayerCell:Output].[Differentiable:TangentVector]
- [RecurrentLayerCell:Output].[Differentiable:TangentVector].[concrete: RNNCellOutput<[RecurrentLayerCell:TimeStepOutput]>.TangentVector : Equatable] => [RecurrentLayerCell:Output].[Differentiable:TangentVector]
- [RecurrentLayerCell:Output].[Differentiable:TangentVector].[concrete: RNNCellOutput<[RecurrentLayerCell].[RecurrentLayerCell:TimeStepOutput]>.TangentVector : AdditiveArithmetic] => [RecurrentLayerCell:Output].[Differentiable:TangentVector] [subst↓]
- [RecurrentLayerCell:Output].[Differentiable:TangentVector].[concrete: RNNCellOutput<[RecurrentLayerCell].[RecurrentLayerCell:TimeStepOutput]>.TangentVector : Differentiable] => [RecurrentLayerCell:Output].[Differentiable:TangentVector] [subst↓]
- [RecurrentLayerCell:Output].[Differentiable:TangentVector].[concrete: RNNCellOutput<[RecurrentLayerCell].[RecurrentLayerCell:TimeStepOutput]>.TangentVector : Equatable] => [RecurrentLayerCell:Output].[Differentiable:TangentVector] [subst↓]
}
Relations: {
- [concrete: RNNCellOutput<[RecurrentLayerCell:TimeStepOutput]>].[Differentiable] =>> [concrete: RNNCellOutput<[RecurrentLayerCell:TimeStepOutput]> : Differentiable]
- [concrete: RNNCellOutput<[RecurrentLayerCell:TimeStepOutput]> : Differentiable].[Differentiable:TangentVector].[concrete: RNNCellOutput<[RecurrentLayerCell:TimeStepOutput]>.TangentVector] =>> [concrete: RNNCellOutput<[RecurrentLayerCell:TimeStepOutput]> : Differentiable].[Differentiable:TangentVector]
- [concrete: RNNCellOutput<[RecurrentLayerCell].[RecurrentLayerCell:TimeStepOutput]>].[Differentiable] =>> [concrete: RNNCellOutput<[RecurrentLayerCell].[RecurrentLayerCell:TimeStepOutput]> : Differentiable]
- [concrete: RNNCellOutput<[RecurrentLayerCell].[RecurrentLayerCell:TimeStepOutput]> : Differentiable].[Differentiable:TangentVector].[concrete: RNNCellOutput<[RecurrentLayerCell].[RecurrentLayerCell:TimeStepOutput]>.TangentVector] =>> [concrete: RNNCellOutput<[RecurrentLayerCell].[RecurrentLayerCell:TimeStepOutput]> : Differentiable].[Differentiable:TangentVector]
- [concrete: RNNCellOutput<[RecurrentLayerCell:TimeStepOutput]>.TangentVector].[AdditiveArithmetic] =>> [concrete: RNNCellOutput<[RecurrentLayerCell:TimeStepOutput]>.TangentVector : AdditiveArithmetic]
- [concrete: RNNCellOutput<[RecurrentLayerCell:TimeStepOutput]>.TangentVector].[Differentiable] =>> [concrete: RNNCellOutput<[RecurrentLayerCell:TimeStepOutput]>.TangentVector : Differentiable]
- [concrete: RNNCellOutput<[RecurrentLayerCell:TimeStepOutput]>.TangentVector : Differentiable].[Differentiable:TangentVector].[concrete: RNNCellOutput<[RecurrentLayerCell:TimeStepOutput]>.TangentVector] =>> [concrete: RNNCellOutput<[RecurrentLayerCell:TimeStepOutput]>.TangentVector : Differentiable].[Differentiable:TangentVector]
- [concrete: RNNCellOutput<[RecurrentLayerCell:TimeStepOutput]>.TangentVector : Differentiable].[Differentiable:TangentVector].[concrete: RNNCellOutput<[RecurrentLayerCell:TimeStepOutput]>.TangentVector] =>> [concrete: RNNCellOutput<[RecurrentLayerCell:TimeStepOutput]>.TangentVector : Differentiable]
- [concrete: RNNCellOutput<[RecurrentLayerCell:TimeStepOutput]>.TangentVector].[Equatable] =>> [concrete: RNNCellOutput<[RecurrentLayerCell:TimeStepOutput]>.TangentVector : Equatable]
- [concrete: RNNCellOutput<[RecurrentLayerCell].[RecurrentLayerCell:TimeStepOutput]>.TangentVector].[AdditiveArithmetic] =>> [concrete: RNNCellOutput<[RecurrentLayerCell].[RecurrentLayerCell:TimeStepOutput]>.TangentVector : AdditiveArithmetic]
- [concrete: RNNCellOutput<[RecurrentLayerCell].[RecurrentLayerCell:TimeStepOutput]>.TangentVector].[Differentiable] =>> [concrete: RNNCellOutput<[RecurrentLayerCell].[RecurrentLayerCell:TimeStepOutput]>.TangentVector : Differentiable]
- [concrete: RNNCellOutput<[RecurrentLayerCell].[RecurrentLayerCell:TimeStepOutput]>.TangentVector : Differentiable].[Differentiable:TangentVector].[concrete: RNNCellOutput<[RecurrentLayerCell].[RecurrentLayerCell:TimeStepOutput]>.TangentVector] =>> [concrete: RNNCellOutput<[RecurrentLayerCell].[RecurrentLayerCell:TimeStepOutput]>.TangentVector : Differentiable].[Differentiable:TangentVector]
- [concrete: RNNCellOutput<[RecurrentLayerCell].[RecurrentLayerCell:TimeStepOutput]>.TangentVector].[Equatable] =>> [concrete: RNNCellOutput<[RecurrentLayerCell].[RecurrentLayerCell:TimeStepOutput]>.TangentVector : Equatable]
}
Type differences: {
Base term: [RecurrentLayerCell:Input]
LHS: [concrete: RNNCellInput<[RecurrentLayerCell].[RecurrentLayerCell:TimeStepInput]>]
RHS: [concrete: RNNCellInput<[RecurrentLayerCell:TimeStepInput]>]
- [RecurrentLayerCell].[RecurrentLayerCell:TimeStepInput] (#0) -> [RecurrentLayerCell:TimeStepInput]

Base term: [RecurrentLayerCell:Output]
LHS: [concrete: RNNCellOutput<[RecurrentLayerCell].[RecurrentLayerCell:TimeStepOutput]>]
RHS: [concrete: RNNCellOutput<[RecurrentLayerCell:TimeStepOutput]>]
- [RecurrentLayerCell].[RecurrentLayerCell:TimeStepOutput] (#0) -> [RecurrentLayerCell:TimeStepOutput]

Base term: [RecurrentLayerCell:Output]
LHS: [concrete: RNNCellOutput<[RecurrentLayerCell].[RecurrentLayerCell:TimeStepOutput]>.TangentVector]
RHS: [concrete: RNNCellOutput<[RecurrentLayerCell:TimeStepOutput]>.TangentVector]
- [RecurrentLayerCell].[RecurrentLayerCell:TimeStepOutput] (#0) -> [RecurrentLayerCell:TimeStepOutput]

Base term: [RecurrentLayerCell:Output]
LHS: [concrete: RNNCellOutput<[RecurrentLayerCell].[RecurrentLayerCell:TimeStepOutput]> : Differentiable]
RHS: [concrete: RNNCellOutput<[RecurrentLayerCell:TimeStepOutput]> : Differentiable]
- [RecurrentLayerCell].[RecurrentLayerCell:TimeStepOutput] (#0) -> [RecurrentLayerCell:TimeStepOutput]

Base term: [RecurrentLayerCell:Output].[Differentiable:TangentVector]
LHS: [concrete: RNNCellOutput<[RecurrentLayerCell].[RecurrentLayerCell:TimeStepOutput]>.TangentVector]
RHS: [concrete: RNNCellOutput<[RecurrentLayerCell:TimeStepOutput]>.TangentVector]
- [RecurrentLayerCell].[RecurrentLayerCell:TimeStepOutput] (#0) -> [RecurrentLayerCell:TimeStepOutput]

Base term: [RecurrentLayerCell:Output].[Differentiable:TangentVector]
LHS: [concrete: RNNCellOutput<[RecurrentLayerCell].[RecurrentLayerCell:TimeStepOutput]>.TangentVector : AdditiveArithmetic]
RHS: [concrete: RNNCellOutput<[RecurrentLayerCell:TimeStepOutput]>.TangentVector : AdditiveArithmetic]
- [RecurrentLayerCell].[RecurrentLayerCell:TimeStepOutput] (#0) -> [RecurrentLayerCell:TimeStepOutput]

Base term: [RecurrentLayerCell:Output].[Differentiable:TangentVector]
LHS: [concrete: RNNCellOutput<[RecurrentLayerCell].[RecurrentLayerCell:TimeStepOutput]>.TangentVector : Differentiable]
RHS: [concrete: RNNCellOutput<[RecurrentLayerCell:TimeStepOutput]>.TangentVector : Differentiable]
- [RecurrentLayerCell].[RecurrentLayerCell:TimeStepOutput] (#0) -> [RecurrentLayerCell:TimeStepOutput]

Base term: [RecurrentLayerCell:Output].[Differentiable:TangentVector]
LHS: [concrete: RNNCellOutput<[RecurrentLayerCell].[RecurrentLayerCell:TimeStepOutput]>.TangentVector : Equatable]
RHS: [concrete: RNNCellOutput<[RecurrentLayerCell:TimeStepOutput]>.TangentVector : Equatable]
- [RecurrentLayerCell].[RecurrentLayerCell:TimeStepOutput] (#0) -> [RecurrentLayerCell:TimeStepOutput]

}
}
Property map: {
  [RecurrentLayerCell] => { conforms_to: [RecurrentLayerCell CaseIterable Layer Differentiable] }
  [CaseIterable] => { conforms_to: [CaseIterable] }
  [Layer] => { conforms_to: [Layer Differentiable] }
  [Differentiable] => { conforms_to: [Differentiable] }
  [Collection] => { conforms_to: [Collection Sequence] }
  [AdditiveArithmetic] => { conforms_to: [AdditiveArithmetic Equatable] }
  [Sequence] => { conforms_to: [Sequence] }
  [Comparable] => { conforms_to: [Comparable Equatable] }
  [Equatable] => { conforms_to: [Equatable] }
  [IteratorProtocol] => { conforms_to: [IteratorProtocol] }
  [RecurrentLayerCell:Input] => { concrete_type: [concrete: RNNCellInput<[RecurrentLayerCell:TimeStepInput]>] }
  [RecurrentLayerCell:Output] => { conforms_to: [Differentiable] concrete_type: [concrete: RNNCellOutput<[RecurrentLayerCell:TimeStepOutput]>] }
  [RecurrentLayerCell:TimeStepOutput] => { conforms_to: [Differentiable] }
  [CaseIterable:AllCases] => { conforms_to: [Collection Sequence] }
  [Layer:Output] => { conforms_to: [Differentiable] }
  [Differentiable:TangentVector] => { conforms_to: [AdditiveArithmetic Differentiable Equatable] }
  [Collection:Index] => { conforms_to: [Comparable Equatable] }
  [Collection:Indices] => { conforms_to: [Collection Sequence] }
  [Collection:SubSequence] => { conforms_to: [Collection Sequence] }
  [Sequence:Iterator] => { conforms_to: [IteratorProtocol] }
  τ_0_0 => { conforms_to: [RecurrentLayerCell CaseIterable Layer Differentiable] }
  [RecurrentLayerCell:AllCases] => { conforms_to: [Collection Sequence] }
  [Layer:TangentVector] => { conforms_to: [AdditiveArithmetic Differentiable Equatable] }
  [Collection:Iterator] => { conforms_to: [IteratorProtocol] }
  [RecurrentLayerCell:TangentVector] => { conforms_to: [AdditiveArithmetic Differentiable Equatable] }
  [Collection].IndexDistance => { concrete_type: [concrete: Int] }
  [CaseIterable:AllCases].IndexDistance => { concrete_type: [concrete: Int] }
  [Collection:Indices].IndexDistance => { concrete_type: [concrete: Int] }
  [Collection:SubSequence].IndexDistance => { concrete_type: [concrete: Int] }
  [RecurrentLayerCell:AllCases].IndexDistance => { concrete_type: [concrete: Int] }
  [RecurrentLayerCell:Output].[Differentiable:TangentVector] => { conforms_to: [AdditiveArithmetic Differentiable Equatable] concrete_type: [concrete: RNNCellOutput<[RecurrentLayerCell:TimeStepOutput]>.TangentVector] }
}
Conformance access paths: {
}
Stack dump:
0.	Program arguments: /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2022-02-25-a.xctoolchain/usr/bin/swift-frontend -frontend -interpret script.swift -Xllvm -aarch64-use-tbi -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk -color-diagnostics -new-driver-path /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2022-02-25-a.xctoolchain/usr/bin/swift-driver -resource-dir /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2022-02-25-a.xctoolchain/usr/lib/swift -module-name script -target-sdk-version 12.3
1.	Apple Swift version 5.7-dev (LLVM b0b5a8392f56428, Swift 56740867bd7b4ea)
2.	Compiling with the current language version
3.	While evaluating request ASTLoweringRequest(Lowering AST to SIL for module script)
4.	While generating SIL witness table protocol conformance to 'Layer' (at script.swift:6:1) for type 'RecurrentLayer<Cell>' (declared at [script.swift:23:1 - line:33:1] RangeText="struct RecurrentLayer<Cell: RecurrentLayerCell>: Layer {
  typealias Input = Cell.TimeStepInput
  typealias Output = Cell.TimeStepOutput

  var cell: Cell

  @differentiable(reverse)
  func callAsFunction(_ inputs: Cell.TimeStepInput) -> Cell.TimeStepOutput {
    return self(inputs)
  }
")
5.	While generating protocol witness thunk SIL function "@AD__$s6script14RecurrentLayerVyxGAA0C0A2aEP14callAsFunctiony6OutputQz5InputQzFTW_jvp_US".
 for 'callAsFunction(_:)' (at script.swift:30:3)
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  swift-frontend           0x0000000104e79d3c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x0000000104e78f9c llvm::sys::RunSignalHandlers() + 128
2  swift-frontend           0x0000000104e7a3a0 SignalHandler(int) + 304
3  libsystem_platform.dylib 0x000000019cd194c4 _sigtramp + 56
4  libsystem_pthread.dylib  0x000000019cd01ee0 pthread_kill + 288
5  libsystem_c.dylib        0x000000019cc3c340 abort + 168
6  swift-frontend           0x0000000101ba6918 swift::Type llvm::function_ref<swift::Type (swift::SubstitutableType*)>::callback_fn<swift::rewriting::RequirementMachine::getCanonicalTypeInContext(swift::Type, swift::ArrayRefView<swift::Type, swift::GenericTypeParamType*, swift::GenericTypeParamType* swift::staticCastHelper<swift::GenericTypeParamType>(swift::Type const&), true>) const::$_0::operator()(swift::Type) const::'lambda'(swift::SubstitutableType*)>(long, swift::SubstitutableType*) + 0
7  swift-frontend           0x0000000101bfdcc4 swift::Type::transformWithPosition(swift::TypePosition, llvm::function_ref<llvm::Optional<swift::Type> (swift::TypeBase*, swift::TypePosition)>) const + 112
8  swift-frontend           0x0000000101c00468 swift::Type::transformRec(llvm::function_ref<llvm::Optional<swift::Type> (swift::TypeBase*)>) const + 36
9  swift-frontend           0x0000000101ba4754 swift::rewriting::RequirementMachine::getCanonicalTypeInContext(swift::Type, swift::ArrayRefView<swift::Type, swift::GenericTypeParamType*, swift::GenericTypeParamType* swift::staticCastHelper<swift::GenericTypeParamType>(swift::Type const&), true>) const + 56
10 swift-frontend           0x0000000101ade71c swift::GenericSignatureImpl::getCanonicalTypeInContext(swift::Type) const + 188
11 swift-frontend           0x0000000101bf331c swift::TypeBase::getCanonicalType(swift::GenericSignature) + 32
12 swift-frontend           0x0000000100a80d9c swift::Lowering::AbstractionPattern::unsafeGetSubstFieldType(swift::ValueDecl*, swift::CanType) const + 316
13 swift-frontend           0x0000000100b31414 (anonymous namespace)::LowerType::visitAnyStructType(swift::CanType, swift::Lowering::AbstractionPattern, swift::StructDecl*, swift::Lowering::IsTypeExpansionSensitive_t) + 544
14 swift-frontend           0x0000000100b23be4 swift::CanTypeVisitor<(anonymous namespace)::LowerType, swift::Lowering::TypeLowering*, swift::Lowering::AbstractionPattern, swift::Lowering::IsTypeExpansionSensitive_t>::visit(swift::CanType, swift::Lowering::AbstractionPattern, swift::Lowering::IsTypeExpansionSensitive_t) + 1468
15 swift-frontend           0x0000000100b23490 swift::Lowering::TypeConverter::getTypeLowering(swift::Lowering::AbstractionPattern, swift::Type, swift::TypeExpansionContext) + 660
16 swift-frontend           0x0000000100ab04b4 (anonymous namespace)::DestructureInputs::visit(swift::ValueOwnership, bool, swift::Lowering::AbstractionPattern, swift::CanType, bool, bool) + 184
17 swift-frontend           0x0000000100aae98c getSILFunctionType(swift::Lowering::TypeConverter&, swift::TypeExpansionContext, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::SILExtInfoBuilder, (anonymous namespace)::Conventions const&, swift::ForeignInfo const&, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SubstitutionMap>, swift::ProtocolConformanceRef, llvm::Optional<llvm::SmallBitVector>) + 2584
18 swift-frontend           0x0000000100aadf08 getNativeSILFunctionType(swift::Lowering::TypeConverter&, swift::TypeExpansionContext, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::SILExtInfoBuilder, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SubstitutionMap>, swift::ProtocolConformanceRef, llvm::Optional<llvm::SmallBitVector>)::$_12::operator()((anonymous namespace)::Conventions const&) const + 316
19 swift-frontend           0x0000000100aa779c getNativeSILFunctionType(swift::Lowering::TypeConverter&, swift::TypeExpansionContext, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::SILExtInfoBuilder, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SubstitutionMap>, swift::ProtocolConformanceRef, llvm::Optional<llvm::SmallBitVector>) + 508
20 swift-frontend           0x0000000100aa7554 swift::getNativeSILFunctionType(swift::Lowering::TypeConverter&, swift::TypeExpansionContext, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::SILExtInfo, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SubstitutionMap>, swift::ProtocolConformanceRef) + 104
21 swift-frontend           0x0000000100b34e08 swift::Lowering::TypeConverter::computeLoweredRValueType(swift::TypeExpansionContext, swift::Lowering::AbstractionPattern, swift::CanType)::LoweredRValueTypeVisitor::visitAnyFunctionType(swift::CanTypeWrapper<swift::AnyFunctionType>) + 736
22 swift-frontend           0x0000000100b24ab0 swift::CanTypeVisitor<swift::Lowering::TypeConverter::computeLoweredRValueType(swift::TypeExpansionContext, swift::Lowering::AbstractionPattern, swift::CanType)::LoweredRValueTypeVisitor, swift::CanType>::visit(swift::CanType) + 432
23 swift-frontend           0x0000000100b2344c swift::Lowering::TypeConverter::getTypeLowering(swift::Lowering::AbstractionPattern, swift::Type, swift::TypeExpansionContext) + 592
24 swift-frontend           0x0000000100aaff08 (anonymous namespace)::DestructureResults::destructure(swift::Lowering::AbstractionPattern, swift::CanType) + 248
25 swift-frontend           0x0000000100aafe94 (anonymous namespace)::DestructureResults::destructure(swift::Lowering::AbstractionPattern, swift::CanType) + 132
26 swift-frontend           0x0000000100aaec48 getSILFunctionType(swift::Lowering::TypeConverter&, swift::TypeExpansionContext, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::SILExtInfoBuilder, (anonymous namespace)::Conventions const&, swift::ForeignInfo const&, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SubstitutionMap>, swift::ProtocolConformanceRef, llvm::Optional<llvm::SmallBitVector>) + 3284
27 swift-frontend           0x0000000100aadf08 getNativeSILFunctionType(swift::Lowering::TypeConverter&, swift::TypeExpansionContext, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::SILExtInfoBuilder, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SubstitutionMap>, swift::ProtocolConformanceRef, llvm::Optional<llvm::SmallBitVector>)::$_12::operator()((anonymous namespace)::Conventions const&) const + 316
28 swift-frontend           0x0000000100aa779c getNativeSILFunctionType(swift::Lowering::TypeConverter&, swift::TypeExpansionContext, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::SILExtInfoBuilder, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SubstitutionMap>, swift::ProtocolConformanceRef, llvm::Optional<llvm::SmallBitVector>) + 508
29 swift-frontend           0x0000000100aa8d88 getUncachedSILFunctionTypeForConstant(swift::Lowering::TypeConverter&, swift::TypeExpansionContext, swift::SILDeclRef, swift::Lowering::TypeConverter::LoweredFormalTypes) + 1920
30 swift-frontend           0x0000000100aa96bc swift::Lowering::TypeConverter::getConstantInfo(swift::TypeExpansionContext, swift::SILDeclRef) + 216
31 swift-frontend           0x0000000100fb796c swift::Lowering::SILGenFunction::emitProtocolWitness(swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::SILDeclRef, swift::SubstitutionMap, swift::SILDeclRef, swift::SubstitutionMap, swift::Lowering::IsFreeFunctionWitness_t, bool) + 680
32 swift-frontend           0x0000000100fcf888 swift::Lowering::SILGenModule::emitProtocolWitness(swift::ProtocolConformanceRef, swift::SILLinkage, swift::IsSerialized_t, swift::SILDeclRef, swift::SILDeclRef, swift::Lowering::IsFreeFunctionWitness_t, swift::Witness) + 2452
33 swift-frontend           0x0000000100fd1a5c (anonymous namespace)::SILGenWitnessTable<(anonymous namespace)::SILGenConformance>::addMethodImplementation(swift::SILDeclRef, swift::SILDeclRef, swift::Witness) + 448
34 swift-frontend           0x0000000100fd1698 (anonymous namespace)::SILGenWitnessTable<(anonymous namespace)::SILGenConformance>::addMethod(swift::SILDeclRef) + 816
35 swift-frontend           0x0000000100fd17e8 swift::SILWitnessVisitor<(anonymous namespace)::SILGenConformance>::addAutoDiffDerivativeMethodsIfRequired(swift::AbstractFunctionDecl*, swift::SILDeclRef::Kind) + 260
36 swift-frontend           0x0000000100fd1198 swift::SILWitnessVisitor<(anonymous namespace)::SILGenConformance>::visitProtocolDecl(swift::ProtocolDecl*) + 1936
37 swift-frontend           0x0000000100fced88 swift::Lowering::SILGenModule::getWitnessTable(swift::NormalProtocolConformance*) + 328
38 swift-frontend           0x0000000100fd07f8 (anonymous namespace)::SILGenType::emitType() + 1708
39 swift-frontend           0x0000000100fd0140 swift::Lowering::SILGenModule::visitNominalTypeDecl(swift::NominalTypeDecl*) + 24
40 swift-frontend           0x0000000100f16d70 swift::ASTLoweringRequest::evaluate(swift::Evaluator&, swift::ASTLoweringDescriptor) const + 1792
41 swift-frontend           0x0000000100fc4040 swift::SimpleRequest<swift::ASTLoweringRequest, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> > (swift::ASTLoweringDescriptor), (swift::RequestFlags)9>::evaluateRequest(swift::ASTLoweringRequest const&, swift::Evaluator&) + 156
42 swift-frontend           0x0000000100f1ad14 llvm::Expected<swift::ASTLoweringRequest::OutputType> swift::Evaluator::getResultUncached<swift::ASTLoweringRequest>(swift::ASTLoweringRequest const&) + 408
43 swift-frontend           0x0000000100f1789c swift::performASTLowering(swift::ModuleDecl*, swift::Lowering::TypeConverter&, swift::SILOptions const&) + 144
44 swift-frontend           0x00000001009f80ac swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 988
45 swift-frontend           0x00000001009f9b6c swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2936
46 swift-frontend           0x000000010090d9d0 swift::mainEntry(int, char const**) + 3748
47 dyld                     0x000000010d66d088 start + 516
zsh: abort      swift script.swift

@slavapestov
Copy link
Contributor Author

That sounds fine then -- the GenericSignatureBuilder is deprecated and will soon be removed anyway.

@philipturner
Copy link
Contributor

I just want to be 100% sure I'm understanding your response correctly. It is fine to add a regression test for SR-15884 to apple/swift, correct?

@slavapestov
Copy link
Contributor Author

Yeah, sure!

@philipturner
Copy link
Contributor

@slavapestov this PR fixed a major bug impacting Swift for TensorFlow, which had forced me to disable large chunks of the code base (s4tf/s4tf#6). I could have evaded the bug by passing -requirement-machine-abstract-signatures=enabled into the compiler. Instead, I only ever tried -requirement-machine-abstract-signatures=on - not the correct way to enable RQM. Anyway, this PR fixed the bug by forcing RQM abstract signatures to be on by default.

Just to correct myself, I wasn't able to avoid the GSB bug by passing -requirement-machine-abstract-signatures=enabled or -requirement-machine-abstract-signatures=on into the compiler. I also tried it with protocol-signatures instead of abstract-signatures. Today, I tried this on the February 22, 2022 and the March 22, 2022 development snapshots with no luck. Perhaps the setting changed by this commit was so hard-coded into the compiler that you couldn't override it at the command line.

When I remove the SR-15884 workaround from S4TF, there will be no way it can compile on these older toolchains. I can at least set up a sr15884 branch for the repo's state before the workarounds are removed. However, it does compile on newer toolchains, which are my dominant use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants