swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
66.68k stars 10.28k forks source link

Compiler crashes in ASTMangler.cpp:1558 "Cannot mangle free-standing archetypes" both in 6.0/5.10 #74569

Open hassila opened 1 week ago

hassila commented 1 week ago

Description

Compiler crashes here: https://github.com/apple/swift/blob/70c54bb73980c94b975c7d9d8d6e2b0d78d731b6/lib/AST/ASTMangler.cpp#L1558C1-L1559C1

(WAS: I can attach the file that produces the crash, have been trying to reduce it but not succeeded so far. NOW, see reproducer below)

Reproduction

protocol Cache<Object> {
    associatedtype Object
    associatedtype Snapshot: Sequence<Object>

    func entries(_ body: (Snapshot) -> Void) -> AsyncStream<Object>
}

func readFromCacheImpl<T>(cache: any Cache<T>) async {
    let updateStream = cache.entries { _ in }

    for await _ in updateStream {}
}

Stack dump

Cannot mangle free-standing archetypes
UNREACHABLE executed at /Users/ec2-user/jenkins/workspace/oss-swift-6.0-package-macos/swift/lib/AST/ASTMangler.cpp:1558!
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.  Program arguments: /Library/Developer/Toolchains/swift-6.0-DEVELOPMENT-SNAPSHOT-2024-06-19-a.xctoolchain/usr/bin/swift-frontend -frontend -c /Users/hassila/GitHub/ordo/Frontend/Sources/OrdoObjectCacheSupport/PublicTradeStatisticsCollector.swift -primary-file /Users/hassila/GitHub/ordo/Frontend/Sources/OrdoObjectCacheSupport/OrdoObjectCache.swift -emit-dependencies-path /Users/hassila/Library/Developer/Xcode/DerivedData/Ordo-gmejvaknewiunvewtbtnixiriytp/Build/Intermediates.noindex/Ordo.build/Debug/OrdoObjectCacheSupport.build/Objects-normal/arm64/OrdoObjectCache.d -emit-const-values-path /Users/hassila/Library/Developer/Xcode/DerivedData/Ordo-gmejvaknewiunvewtbtnixiriytp/Build/Intermediates.noindex/Ordo.build/Debug/OrdoObjectCacheSupport.build/Objects-normal/arm64/OrdoObjectCache.swiftconstvalues -emit-reference-dependencies-path /Users/hassila/Library/Developer/Xcode/DerivedData/Ordo-gmejvaknewiunvewtbtnixiriytp/Build/Intermediates.noindex/Ordo.build/Debug/OrdoObjectCacheSupport.build/Objects-normal/arm64/OrdoObjectCache.swiftdeps -serialize-diagnostics-path /Users/hassila/Library/Developer/Xcode/DerivedData/Ordo-gmejvaknewiunvewtbtnixiriytp/Build/Intermediates.noindex/Ordo.build/Debug/OrdoObjectCacheSupport.build/Objects-normal/arm64/OrdoObjectCache.dia -target arm64-apple-macos14.4 -Xllvm -aarch64-use-tbi -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk -I /Users/hassila/Library/Developer/Xcode/DerivedData/Ordo-gmejvaknewiunvewtbtnixiriytp/Build/Products/Debug -F /Users/hassila/Library/Developer/Xcode/DerivedData/Ordo-gmejvaknewiunvewtbtnixiriytp/Build/Products/Debug/PackageFrameworks -F /Users/hassila/Library/Developer/Xcode/DerivedData/Ordo-gmejvaknewiunvewtbtnixiriytp/Build/Products/Debug/PackageFrameworks -F /Users/hassila/Library/Developer/Xcode/DerivedData/Ordo-gmejvaknewiunvewtbtnixiriytp/Build/Products/Debug/PackageFrameworks -F /Users/hassila/Library/Developer/Xcode/DerivedData/Ordo-gmejvaknewiunvewtbtnixiriytp/Build/Products/Debug/PackageFrameworks -F /Users/hassila/Library/Developer/Xcode/DerivedData/Ordo-gmejvaknewiunvewtbtnixiriytp/Build/Products/Debug/PackageFrameworks -F /Users/hassila/Library/Developer/Xcode/DerivedData/Ordo-gmejvaknewiunvewtbtnixiriytp/Build/Products/Debug/PackageFrameworks -F /Users/hassila/Library/Developer/Xcode/DerivedData/Ordo-gmejvaknewiunvewtbtnixiriytp/Build/Products/Debug/PackageFrameworks -F /Users/hassila/Library/Developer/Xcode/DerivedData/Ordo-gmejvaknewiunvewtbtnixiriytp/Build/Products/Debug/PackageFrameworks -F /Users/hassila/Library/Developer/Xcode/DerivedData/Ordo-gmejvaknewiunvewtbtnixiriytp/Build/Products/Debug/PackageFrameworks -F /Users/hassila/Library/Developer/Xcode/DerivedData/Ordo-gmejvaknewiunvewtbtnixiriytp/Build/Products/Debug/PackageFrameworks -F /Users/hassila/Library/Developer/Xcode/DerivedData/Ordo-gmejvaknewiunvewtbtnixiriytp/Build/Products/Debug/PackageFrameworks -F /Users/hassila/Library/Developer/Xcode/DerivedData/Ordo-gmejvaknewiunvewtbtnixiriytp/Build/Products/Debug/PackageFrameworks -F /Users/hassila/Library/Developer/Xcode/DerivedData/Ordo-gmejvaknewiunvewtbtnixiriytp/Build/Products/Debug/PackageFrameworks -F /Users/hassila/Library/Developer/Xcode/DerivedData/Ordo-gmejvaknewiunvewtbtnixiriytp/Build/Products/Debug/PackageFrameworks -F /Users/hassila/Library/Developer/Xcode/DerivedData/Ordo-gmejvaknewiunvewtbtnixiriytp/Build/Products/Debug/PackageFrameworks -F /Users/hassila/Library/Developer/Xcode/DerivedData/Ordo-gmejvaknewiunvewtbtnixiriytp/Build/Products/Debug -no-color-diagnostics -enable-library-evolution -enable-testing -g -module-cache-path /Users/hassila/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -swift-version 5 -enforce-exclusivity=checked -Onone -D DEBUG -D ORDO_BUILDING_IN_XCODE -serialize-debugging-options -const-gather-protocols-file /Users/hassila/Library/Developer/Xcode/DerivedData/Ordo-gmejvaknewiunvewtbtnixiriytp/Build/Intermediates.noindex/Ordo.build/Debug/OrdoObjectCacheSupport.build/Objects-normal/arm64/OrdoObjectCacheSupport_const_extract_protocols.json -enable-bare-slash-regex -plugin-path /Library/Developer/Toolchains/swift-6.0-DEVELOPMENT-SNAPSHOT-2024-06-19-a.xctoolchain/usr/lib/swift/host/plugins -validate-clang-modules-once -clang-build-session-file /Users/hassila/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation -Xcc -working-directory -Xcc /Users/hassila/GitHub/ordo/Frontend -resource-dir /Library/Developer/Toolchains/swift-6.0-DEVELOPMENT-SNAPSHOT-2024-06-19-a.xctoolchain/usr/lib/swift -enable-anonymous-context-mangled-names -Xcc -I/Users/hassila/Library/Developer/Xcode/DerivedData/Ordo-gmejvaknewiunvewtbtnixiriytp/Build/Intermediates.noindex/Ordo.build/Debug/OrdoObjectCacheSupport.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/hassila/Library/Developer/Xcode/DerivedData/Ordo-gmejvaknewiunvewtbtnixiriytp/Build/Intermediates.noindex/Ordo.build/Debug/OrdoObjectCacheSupport.build/OrdoObjectCacheSupport-generated-files.hmap -Xcc -I/Users/hassila/Library/Developer/Xcode/DerivedData/Ordo-gmejvaknewiunvewtbtnixiriytp/Build/Intermediates.noindex/Ordo.build/Debug/OrdoObjectCacheSupport.build/OrdoObjectCacheSupport-own-target-headers.hmap -Xcc -I/Users/hassila/Library/Developer/Xcode/DerivedData/Ordo-gmejvaknewiunvewtbtnixiriytp/Build/Intermediates.noindex/Ordo.build/Debug/OrdoObjectCacheSupport.build/OrdoObjectCacheSupport-all-non-framework-target-headers.hmap -Xcc -ivfsoverlay -Xcc /Users/hassila/Library/Developer/Xcode/DerivedData/Ordo-gmejvaknewiunvewtbtnixiriytp/Build/Intermediates.noindex/Ordo.build/Debug/OrdoObjectCacheSupport.build/all-product-headers.yaml -Xcc -iquote -Xcc /Users/hassila/Library/Developer/Xcode/DerivedData/Ordo-gmejvaknewiunvewtbtnixiriytp/Build/Intermediates.noindex/Ordo.build/Debug/OrdoObjectCacheSupport.build/OrdoObjectCacheSupport-project-headers.hmap -Xcc -I/Users/hassila/Library/Developer/Xcode/DerivedData/Ordo-gmejvaknewiunvewtbtnixiriytp/SourcePackages/checkouts/swift-numerics/Sources/_NumericsShims/include -Xcc -I/Users/hassila/Library/Developer/Xcode/DerivedData/Ordo-gmejvaknewiunvewtbtnixiriytp/Build/Products/Debug/include -Xcc -I/Users/hassila/Library/Developer/Xcode/DerivedData/Ordo-gmejvaknewiunvewtbtnixiriytp/Build/Intermediates.noindex/Ordo.build/Debug/OrdoObjectCacheSupport.build/DerivedSources-normal/arm64 -Xcc -I/Users/hassila/Library/Developer/Xcode/DerivedData/Ordo-gmejvaknewiunvewtbtnixiriytp/Build/Intermediates.noindex/Ordo.build/Debug/OrdoObjectCacheSupport.build/DerivedSources/arm64 -Xcc -I/Users/hassila/Library/Developer/Xcode/DerivedData/Ordo-gmejvaknewiunvewtbtnixiriytp/Build/Intermediates.noindex/Ordo.build/Debug/OrdoObjectCacheSupport.build/DerivedSources -Xcc -DDEBUG=1 -module-name OrdoObjectCacheSupport -frontend-parseable-output -disable-clang-spi -target-sdk-version 14.5 -target-sdk-name macosx14.5 -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/local/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/local/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -plugin-path /Library/Developer/Toolchains/swift-6.0-DEVELOPMENT-SNAPSHOT-2024-06-19-a.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Library/Developer/Toolchains/swift-6.0-DEVELOPMENT-SNAPSHOT-2024-06-19-a.xctoolchain/usr/local/lib/swift/host/plugins -o /Users/hassila/Library/Developer/Xcode/DerivedData/Ordo-gmejvaknewiunvewtbtnixiriytp/Build/Intermediates.noindex/Ordo.build/Debug/OrdoObjectCacheSupport.build/Objects-normal/arm64/OrdoObjectCache.o -index-unit-output-path /Ordo.build/Debug/OrdoObjectCacheSupport.build/Objects-normal/arm64/OrdoObjectCache.o -index-store-path /Users/hassila/Library/Developer/Xcode/DerivedData/Ordo-gmejvaknewiunvewtbtnixiriytp/Index.noindex/DataStore -index-system-modules
1.  Apple Swift version 6.0-dev (LLVM 5f87d6ee2f8c800, Swift 5c01ca13866debd)
2.  Compiling with effective version 5.10
3.  While evaluating request ASTLoweringRequest(Lowering AST to SIL for file "/Users/hassila/GitHub/ordo/Frontend/Sources/OrdoObjectCacheSupport/OrdoObjectCache.swift")
4.  While silgen emitFunction SIL function "@$s22OrdoObjectCacheSupport0abC0C10allObjects5limitSay2IDQzGSi_tF".
 for 'allObjects(limit:)' (at /Users/hassila/GitHub/ordo/Frontend/Sources/OrdoObjectCacheSupport/OrdoObjectCache.swift:120:12)
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           0x0000000108224ebc llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x0000000108223688 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x0000000108225504 SignalHandler(int) + 304
3  libsystem_platform.dylib 0x00000001a0003584 _sigtramp + 56
4  libsystem_pthread.dylib  0x000000019ffd2c20 pthread_kill + 288
5  libsystem_c.dylib        0x000000019fedfa30 abort + 180
6  swift-frontend           0x00000001081a4490 llvm::install_out_of_memory_new_handler() + 0
7  swift-frontend           0x0000000104392b78 swift::Mangle::ASTMangler::appendType(swift::Type, swift::GenericSignature, swift::ValueDecl const*) + 6456
8  swift-frontend           0x000000010439e344 swift::Mangle::ASTMangler::appendRequirement(swift::Requirement const&, swift::GenericSignature, bool) + 164
9  swift-frontend           0x000000010439c954 swift::Mangle::ASTMangler::appendGenericSignatureParts(swift::GenericSignature, swift::Mangle::ASTMangler::GenericSignatureParts const&) + 228
10 swift-frontend           0x00000001043911e8 swift::Mangle::ASTMangler::appendGenericSignature(swift::GenericSignature) + 184
11 swift-frontend           0x0000000104393304 swift::Mangle::ASTMangler::mangleReabstractionThunkHelper(swift::CanTypeWrapper<swift::SILFunctionType>, swift::Type, swift::Type, swift::Type, swift::Type, swift::ModuleDecl*) + 260
12 swift-frontend           0x00000001034a9ef0 swift::Lowering::SILGenModule::getOrCreateReabstractionThunk(swift::CanTypeWrapper<swift::SILFunctionType>, swift::CanTypeWrapper<swift::SILFunctionType>, swift::CanTypeWrapper<swift::SILFunctionType>, swift::CanType, swift::CanType) + 700
13 swift-frontend           0x0000000103487624 createThunk(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::Lowering::ManagedValue, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::Lowering::TypeLowering const&) + 3380
14 swift-frontend           0x000000010347ec30 (anonymous namespace)::Transform::transform(swift::Lowering::ManagedValue, swift::Lowering::AbstractionPattern, swift::CanType, swift::Lowering::AbstractionPattern, swift::CanType, swift::SILType, swift::Lowering::SGFContext) + 2384
15 swift-frontend           0x000000010347e2c0 swift::Lowering::SILGenFunction::emitTransformedValue(swift::SILLocation, swift::Lowering::ManagedValue, swift::CanType, swift::CanType, swift::Lowering::SGFContext) + 232
16 swift-frontend           0x00000001033c0994 (anonymous namespace)::DelayedArgument::finishOriginalExpr(swift::Lowering::SILGenFunction&, swift::Expr*) + 832
17 swift-frontend           0x00000001033bfff0 (anonymous namespace)::DelayedArgument::emit(swift::Lowering::SILGenFunction&, llvm::SmallVectorImpl<swift::Lowering::ManagedValue>&, unsigned long&) + 124
18 swift-frontend           0x00000001033adf54 emitDelayedArguments(swift::Lowering::SILGenFunction&, llvm::MutableArrayRef<(anonymous namespace)::DelayedArgument>, llvm::MutableArrayRef<llvm::SmallVector<swift::Lowering::ManagedValue, 4u>>) + 428
19 swift-frontend           0x00000001033c5f28 (anonymous namespace)::CallEmission::emitArgumentsForNormalApply(swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::SILFunctionType>, swift::ForeignInfo const&, llvm::SmallVectorImpl<swift::Lowering::ManagedValue>&, std::__1::optional<swift::SILLocation>&) + 1104
20 swift-frontend           0x00000001033b1620 (anonymous namespace)::CallEmission::apply(swift::Lowering::SGFContext) + 1800
21 swift-frontend           0x00000001033afcb4 swift::Lowering::SILGenFunction::emitApplyExpr(swift::ApplyExpr*, swift::Lowering::SGFContext) + 2028
22 swift-frontend           0x0000000103424dc8 void llvm::function_ref<void (swift::Expr*)>::callback_fn<swift::Lowering::RValue swift::Lowering::SILGenFunction::emitOpenExistentialExpr<swift::Lowering::RValue, (anonymous namespace)::RValueEmitter::visitOpenExistentialExpr(swift::OpenExistentialExpr*, swift::Lowering::SGFContext)::$_21>(swift::OpenExistentialExpr*, (anonymous namespace)::RValueEmitter::visitOpenExistentialExpr(swift::OpenExistentialExpr*, swift::Lowering::SGFContext)::$_21)::'lambda'(swift::Expr*)>(long, swift::Expr*) + 36
23 swift-frontend           0x00000001034125a0 swift::Lowering::SILGenFunction::emitOpenExistentialExprImpl(swift::OpenExistentialExpr*, llvm::function_ref<void (swift::Expr*)>) + 380
24 swift-frontend           0x000000010341ba68 (anonymous namespace)::RValueEmitter::visitOpenExistentialExpr(swift::OpenExistentialExpr*, swift::Lowering::SGFContext) + 168
25 swift-frontend           0x000000010340bf44 swift::Lowering::SILGenFunction::emitIgnoredExpr(swift::Expr*) + 912
26 swift-frontend           0x00000001034a06a8 swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 4348
27 swift-frontend           0x000000010349f5a0 swift::Lowering::SILGenFunction::emitStmt(swift::Stmt*) + 24
28 swift-frontend           0x000000010342e788 swift::Lowering::SILGenFunction::emitFunction(swift::FuncDecl*) + 432
29 swift-frontend           0x000000010339df40 swift::Lowering::SILGenModule::emitFunctionDefinition(swift::SILDeclRef, swift::SILFunction*) + 6324
30 swift-frontend           0x000000010339edd8 swift::Lowering::SILGenModule::emitOrDelayFunction(swift::SILDeclRef) + 256
31 swift-frontend           0x000000010339c654 swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) + 196
32 swift-frontend           0x00000001034b4368 (anonymous namespace)::SILGenType::visitFuncDecl(swift::FuncDecl*) + 28
33 swift-frontend           0x00000001034b12b4 (anonymous namespace)::SILGenType::emitType() + 276
34 swift-frontend           0x00000001034b1194 swift::Lowering::SILGenModule::visitNominalTypeDecl(swift::NominalTypeDecl*) + 24
35 swift-frontend           0x00000001033a1714 swift::ASTLoweringRequest::evaluate(swift::Evaluator&, swift::ASTLoweringDescriptor) const + 880
36 swift-frontend           0x000000010349eff8 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&) + 148
37 swift-frontend           0x00000001033a7008 swift::ASTLoweringRequest::OutputType swift::Evaluator::getResultUncached<swift::ASTLoweringRequest, swift::ASTLoweringRequest::OutputType swift::evaluateOrFatal<swift::ASTLoweringRequest>(swift::Evaluator&, swift::ASTLoweringRequest)::'lambda'()>(swift::ASTLoweringRequest const&, swift::ASTLoweringRequest::OutputType swift::evaluateOrFatal<swift::ASTLoweringRequest>(swift::Evaluator&, swift::ASTLoweringRequest)::'lambda'()) + 340
38 swift-frontend           0x00000001033a2018 swift::performASTLowering(swift::FileUnit&, swift::Lowering::TypeConverter&, swift::SILOptions const&, swift::IRGenOptions const*) + 96
39 swift-frontend           0x0000000102d87610 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 612
40 swift-frontend           0x0000000102d98964 withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) + 160
41 swift-frontend           0x0000000102d89c9c performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 708
42 swift-frontend           0x0000000102d88c08 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2376
43 swift-frontend           0x0000000102ba2b7c swift::mainEntry(int, char const**) + 3096
44 dyld                     0x000000019fc4a0e0 start + 2360
Command SwiftCompile failed with a nonzero exit code

Expected behavior

No crash would be expected

Environment

This crashed with the latest 6.0 downloaded: https://download.swift.org/swift-6.0-branch/xcode/swift-6.0-DEVELOPMENT-SNAPSHOT-2024-06-19-a/swift-6.0-DEVELOPMENT-SNAPSHOT-2024-06-19-a-osx.pkg

But we originally have the crash in a production released version:

swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Target: arm64-apple-macosx14.0

Additional information

OrdoObjectCache.swift.zip

hassila commented 1 week ago

Commenting out some of the code gives a slightly different backtrace:

1.  Apple Swift version 6.0-dev (LLVM 5f87d6ee2f8c800, Swift 5c01ca13866debd)
2.  Compiling with effective version 5.10
3.  While evaluating request ASTLoweringRequest(Lowering AST to SIL for file "/Users/hassila/GitHub/ordo/Frontend/Sources/OrdoObjectCacheSupport/OrdoObjectCache.swift")
4.  While silgen emitFunction SIL function "@$s22OrdoObjectCacheSupport0abC0C6search3for5limit5count10HeapModule0I0VyAC13SearchResultsVyx_GGSS_S2iztYaKF".
 for 'search(for:limit:count:)' (at /Users/hassila/GitHub/ordo/Frontend/Sources/OrdoObjectCacheSupport/OrdoObjectCache.swift:171:12)
5.  While silgen closureexpr SIL function "@$s22OrdoObjectCacheSupport0abC0C6search3for5limit5count10HeapModule0I0VyAC13SearchResultsVyx_GGSS_S2iztYaKFANScgyShyAMGs5Error_pGzYaKXEfU_".
 for expression at [/Users/hassila/GitHub/ordo/Frontend/Sources/OrdoObjectCacheSupport/OrdoObjectCache.swift:177:78 - line:212:9] RangeText="{ taskGroup in
            var aggregatedResults: Heap<SearchResults> = []
            ordoObjects.entriesSnapshot { snapshot in
                func addTasks(_ snapshot: some PartitionedSequence<CacheUpdate<OrdoObject>.Data>) {
                    for itemSequence in snapshot.partitions {
                        taskGroup.addTask(priority: .utility) {
                            var identifiersForPartition: Set<SearchResults> = []
                            for item in itemSequence {
                                guard case .update(let object, _) = item else { continue }
                                try Task.checkCancellation()
                                let ranking = OrdoObject.ranking(for: string, object: object) // computing ranking is heavy
                                if ranking > 0 {
                                    identifiersForPartition.insert(.init(identifier: object.id, ranking: ranking))
                                }
                            }
                            return identifiersForPartition
                        }
                    }
                }

                addTasks(snapshot)
            }

            for try await items in taskGroup {
                count += items.count
                try items.forEach { searchResult in
                    try Task.checkCancellation()

                    aggregatedResults.insert(searchResult)
                    while aggregatedResults.count > limit {
                        _ = aggregatedResults.popMin()
                    }
                }
            }
            return aggregatedResults
        "
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           0x000000010799cebc llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x000000010799b688 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x000000010799d504 SignalHandler(int) + 304
3  libsystem_platform.dylib 0x00000001a0003584 _sigtramp + 56
4  libsystem_pthread.dylib  0x000000019ffd2c20 pthread_kill + 288
5  libsystem_c.dylib        0x000000019fedfa30 abort + 180
6  swift-frontend           0x000000010791c490 llvm::install_out_of_memory_new_handler() + 0
7  swift-frontend           0x0000000103b0ab78 swift::Mangle::ASTMangler::appendType(swift::Type, swift::GenericSignature, swift::ValueDecl const*) + 6456
8  swift-frontend           0x0000000103b16344 swift::Mangle::ASTMangler::appendRequirement(swift::Requirement const&, swift::GenericSignature, bool) + 164
9  swift-frontend           0x0000000103b14954 swift::Mangle::ASTMangler::appendGenericSignatureParts(swift::GenericSignature, swift::Mangle::ASTMangler::GenericSignatureParts const&) + 228
10 swift-frontend           0x0000000103b091e8 swift::Mangle::ASTMangler::appendGenericSignature(swift::GenericSignature) + 184
11 swift-frontend           0x0000000103b0b304 swift::Mangle::ASTMangler::mangleReabstractionThunkHelper(swift::CanTypeWrapper<swift::SILFunctionType>, swift::Type, swift::Type, swift::Type, swift::Type, swift::ModuleDecl*) + 260
12 swift-frontend           0x0000000102c21ef0 swift::Lowering::SILGenModule::getOrCreateReabstractionThunk(swift::CanTypeWrapper<swift::SILFunctionType>, swift::CanTypeWrapper<swift::SILFunctionType>, swift::CanTypeWrapper<swift::SILFunctionType>, swift::CanType, swift::CanType) + 700
13 swift-frontend           0x0000000102bff624 createThunk(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::Lowering::ManagedValue, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::Lowering::TypeLowering const&) + 3380
14 swift-frontend           0x0000000102bf6c30 (anonymous namespace)::Transform::transform(swift::Lowering::ManagedValue, swift::Lowering::AbstractionPattern, swift::CanType, swift::Lowering::AbstractionPattern, swift::CanType, swift::SILType, swift::Lowering::SGFContext) + 2384
15 swift-frontend           0x0000000102bf62c0 swift::Lowering::SILGenFunction::emitTransformedValue(swift::SILLocation, swift::Lowering::ManagedValue, swift::CanType, swift::CanType, swift::Lowering::SGFContext) + 232
16 swift-frontend           0x0000000102b38994 (anonymous namespace)::DelayedArgument::finishOriginalExpr(swift::Lowering::SILGenFunction&, swift::Expr*) + 832
17 swift-frontend           0x0000000102b37ff0 (anonymous namespace)::DelayedArgument::emit(swift::Lowering::SILGenFunction&, llvm::SmallVectorImpl<swift::Lowering::ManagedValue>&, unsigned long&) + 124
18 swift-frontend           0x0000000102b25f54 emitDelayedArguments(swift::Lowering::SILGenFunction&, llvm::MutableArrayRef<(anonymous namespace)::DelayedArgument>, llvm::MutableArrayRef<llvm::SmallVector<swift::Lowering::ManagedValue, 4u>>) + 428
19 swift-frontend           0x0000000102b3df28 (anonymous namespace)::CallEmission::emitArgumentsForNormalApply(swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::SILFunctionType>, swift::ForeignInfo const&, llvm::SmallVectorImpl<swift::Lowering::ManagedValue>&, std::__1::optional<swift::SILLocation>&) + 1104
20 swift-frontend           0x0000000102b29620 (anonymous namespace)::CallEmission::apply(swift::Lowering::SGFContext) + 1800
21 swift-frontend           0x0000000102b27cb4 swift::Lowering::SILGenFunction::emitApplyExpr(swift::ApplyExpr*, swift::Lowering::SGFContext) + 2028
22 swift-frontend           0x0000000102b9cdc8 void llvm::function_ref<void (swift::Expr*)>::callback_fn<swift::Lowering::RValue swift::Lowering::SILGenFunction::emitOpenExistentialExpr<swift::Lowering::RValue, (anonymous namespace)::RValueEmitter::visitOpenExistentialExpr(swift::OpenExistentialExpr*, swift::Lowering::SGFContext)::$_21>(swift::OpenExistentialExpr*, (anonymous namespace)::RValueEmitter::visitOpenExistentialExpr(swift::OpenExistentialExpr*, swift::Lowering::SGFContext)::$_21)::'lambda'(swift::Expr*)>(long, swift::Expr*) + 36
23 swift-frontend           0x0000000102b8a5a0 swift::Lowering::SILGenFunction::emitOpenExistentialExprImpl(swift::OpenExistentialExpr*, llvm::function_ref<void (swift::Expr*)>) + 380
24 swift-frontend           0x0000000102b93a68 (anonymous namespace)::RValueEmitter::visitOpenExistentialExpr(swift::OpenExistentialExpr*, swift::Lowering::SGFContext) + 168
25 swift-frontend           0x0000000102b83f44 swift::Lowering::SILGenFunction::emitIgnoredExpr(swift::Expr*) + 912
26 swift-frontend           0x0000000102c186a8 swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 4348
27 swift-frontend           0x0000000102c175a0 swift::Lowering::SILGenFunction::emitStmt(swift::Stmt*) + 24
28 swift-frontend           0x0000000102ba69bc swift::Lowering::SILGenFunction::emitClosure(swift::AbstractClosureExpr*) + 420
29 swift-frontend           0x0000000102b15020 swift::Lowering::SILGenModule::emitFunctionDefinition(swift::SILDeclRef, swift::SILFunction*) + 2452
30 swift-frontend           0x0000000102b1e118 void llvm::function_ref<void ()>::callback_fn<swift::Lowering::SILGenModule::emitClosure(swift::AbstractClosureExpr*, swift::Lowering::FunctionTypeInfo const&)::$_4>(long) + 220
31 swift-frontend           0x00000001033f6ae4 swift::Lowering::TypeConverter::withClosureTypeInfo(swift::AbstractClosureExpr*, swift::Lowering::FunctionTypeInfo const&, llvm::function_ref<void ()>) + 160
32 swift-frontend           0x0000000102b17d1c swift::Lowering::SILGenModule::emitClosure(swift::AbstractClosureExpr*, swift::Lowering::FunctionTypeInfo const&) + 152
33 swift-frontend           0x0000000102b9ba54 (anonymous namespace)::RValueEmitter::emitClosureReference(swift::AbstractClosureExpr*, swift::Lowering::FunctionTypeInfo const&) + 64
34 swift-frontend           0x0000000102b9b724 (anonymous namespace)::RValueEmitter::visitAbstractClosureExpr(swift::AbstractClosureExpr*, swift::Lowering::SGFContext) + 512
35 swift-frontend           0x0000000102b8396c swift::Lowering::SILGenFunction::emitRValueAsSingleValue(swift::Expr*, swift::Lowering::SGFContext) + 56
36 swift-frontend           0x0000000102b67d60 swift::Lowering::SILGenFunction::emitConvertedRValue(swift::SILLocation, swift::Lowering::Conversion const&, swift::Lowering::SGFContext, llvm::function_ref<swift::Lowering::ManagedValue (swift::Lowering::SILGenFunction&, swift::SILLocation, swift::Lowering::SGFContext)>) + 328
37 swift-frontend           0x0000000102afcb98 swift::Lowering::ArgumentSource::getConverted(swift::Lowering::SILGenFunction&, swift::Lowering::Conversion const&, swift::Lowering::SGFContext) && + 184
38 swift-frontend           0x0000000102b34c88 (anonymous namespace)::ArgEmitter::emit(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern, std::__1::optional<swift::AnyFunctionType::Param>) + 3948
39 swift-frontend           0x0000000102b25cb4 (anonymous namespace)::ArgEmitter::emitSingleArg(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern, std::__1::optional<swift::AnyFunctionType::Param>) + 312
40 swift-frontend           0x0000000102b33264 (anonymous namespace)::ArgEmitter::emitPreparedArgs(swift::Lowering::PreparedArguments&&, swift::Lowering::AbstractionPattern) + 192
41 swift-frontend           0x0000000102b3e520 (anonymous namespace)::CallSite::emit(swift::Lowering::SILGenFunction&, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::SILFunctionType>, (anonymous namespace)::ParamLowering&, llvm::SmallVectorImpl<swift::Lowering::ManagedValue>&, llvm::SmallVectorImpl<(anonymous namespace)::DelayedArgument>&, swift::ForeignInfo const&) && + 532
42 swift-frontend           0x0000000102b3dee8 (anonymous namespace)::CallEmission::emitArgumentsForNormalApply(swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::SILFunctionType>, swift::ForeignInfo const&, llvm::SmallVectorImpl<swift::Lowering::ManagedValue>&, std::__1::optional<swift::SILLocation>&) + 1040
43 swift-frontend           0x0000000102b29620 (anonymous namespace)::CallEmission::apply(swift::Lowering::SGFContext) + 1800
44 swift-frontend           0x0000000102b27cb4 swift::Lowering::SILGenFunction::emitApplyExpr(swift::ApplyExpr*, swift::Lowering::SGFContext) + 2028
45 swift-frontend           0x0000000102b8126c swift::Lowering::SILGenFunction::emitRValue(swift::Expr*, swift::Lowering::SGFContext) + 40
46 swift-frontend           0x0000000102c1ae04 swift::Lowering::SILGenFunction::emitReturnExpr(swift::SILLocation, swift::Expr*) + 584
47 swift-frontend           0x0000000102c19090 swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 6884
48 swift-frontend           0x0000000102c1871c swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 4464
49 swift-frontend           0x0000000102c175a0 swift::Lowering::SILGenFunction::emitStmt(swift::Stmt*) + 24
50 swift-frontend           0x0000000102ba6788 swift::Lowering::SILGenFunction::emitFunction(swift::FuncDecl*) + 432
51 swift-frontend           0x0000000102b15f40 swift::Lowering::SILGenModule::emitFunctionDefinition(swift::SILDeclRef, swift::SILFunction*) + 6324
52 swift-frontend           0x0000000102b16dd8 swift::Lowering::SILGenModule::emitOrDelayFunction(swift::SILDeclRef) + 256
53 swift-frontend           0x0000000102b14654 swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) + 196
54 swift-frontend           0x0000000102c2c368 (anonymous namespace)::SILGenType::visitFuncDecl(swift::FuncDecl*) + 28
55 swift-frontend           0x0000000102c292b4 (anonymous namespace)::SILGenType::emitType() + 276
56 swift-frontend           0x0000000102c29194 swift::Lowering::SILGenModule::visitNominalTypeDecl(swift::NominalTypeDecl*) + 24
57 swift-frontend           0x0000000102b19714 swift::ASTLoweringRequest::evaluate(swift::Evaluator&, swift::ASTLoweringDescriptor) const + 880
58 swift-frontend           0x0000000102c16ff8 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&) + 148
59 swift-frontend           0x0000000102b1f008 swift::ASTLoweringRequest::OutputType swift::Evaluator::getResultUncached<swift::ASTLoweringRequest, swift::ASTLoweringRequest::OutputType swift::evaluateOrFatal<swift::ASTLoweringRequest>(swift::Evaluator&, swift::ASTLoweringRequest)::'lambda'()>(swift::ASTLoweringRequest const&, swift::ASTLoweringRequest::OutputType swift::evaluateOrFatal<swift::ASTLoweringRequest>(swift::Evaluator&, swift::ASTLoweringRequest)::'lambda'()) + 340
60 swift-frontend           0x0000000102b1a018 swift::performASTLowering(swift::FileUnit&, swift::Lowering::TypeConverter&, swift::SILOptions const&, swift::IRGenOptions const*) + 96
61 swift-frontend           0x00000001024ff610 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 612
62 swift-frontend           0x0000000102510964 withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) + 160
63 swift-frontend           0x0000000102501c9c performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 708
64 swift-frontend           0x0000000102500c08 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2376
65 swift-frontend           0x000000010231ab7c swift::mainEntry(int, char const**) + 3096
66 dyld                     0x000000019fc4a0e0 start + 2360
hassila commented 1 week ago

Commenting out the following blocks makes the file compile:

//    public func allObjects(limit: Int = 100) -> [OrdoObject.ID] {
//        guard limit <= 100 else {
//            preconditionFailure("OrdoObjectCache.allObjects: Requesting more than 100 objects is not recommended")
//        }
//
//        var objects: [OrdoObject.ID] = []
//
//        ordoObjects.entriesSnapshot { sequence in
//            for item in sequence {
//                if case let .update(object, _) = item {
//                    objects.append(object.id)
//
//                    guard objects.count < limit else {
//                        return
//                    }
//                }
//            }
//        }
//
//        return objects
//    }

    /// Synchronous non-interruptable search for smaller caches like Users and Accounts, used e.g. by the order panel to get the best matching single item
    public func search(for string: String) -> OrdoObject? {
//        var maxRanking = 0
//        var currentId: OrdoObject.ID?
//
//        ordoObjects.entriesSnapshot { sequence in
//            for item in sequence {
//                guard case .update(let object, _) = item else { continue }
//                let ranking = OrdoObject.ranking(for: string, object: object) // computing ranking is heavy
//                if ranking > maxRanking {
//                    maxRanking = ranking
//                    currentId = object.id
//                }
//            }
//        }
//        if let currentId {
//            return self[currentId]
//        }
        return nil
    }

    public func search(
        for string: String,
        limit: Int = .max
    ) async throws -> Heap<SearchResults> {
        var count = 0
        return try await search(for: string, limit: limit, count: &count)
    }

    public func search(
        for string: String,
        limit: Int = .max,
        count: inout Int
    ) async throws -> Heap<SearchResults> {
        return .init()
/*        try await withThrowingTaskGroup(of: Set<SearchResults>.self,
                                        returning: Heap<SearchResults>.self) { taskGroup in
            var aggregatedResults: Heap<SearchResults> = []
            ordoObjects.entriesSnapshot { snapshot in
                func addTasks(_ snapshot: some PartitionedSequence<CacheUpdate<OrdoObject>.Data>) {
                    for itemSequence in snapshot.partitions {
                        taskGroup.addTask(priority: .utility) {
                            var identifiersForPartition: Set<SearchResults> = []
                            for item in itemSequence {
                                guard case .update(let object, _) = item else { continue }
                                try Task.checkCancellation()
                                let ranking = OrdoObject.ranking(for: string, object: object) // computing ranking is heavy
                                if ranking > 0 {
                                    identifiersForPartition.insert(.init(identifier: object.id, ranking: ranking))
                                }
                            }
                            return identifiersForPartition
                        }
                    }
                }

                addTasks(snapshot)
            }

            for try await items in taskGroup {
                count += items.count
                try items.forEach { searchResult in
                    try Task.checkCancellation()

                    aggregatedResults.insert(searchResult)
                    while aggregatedResults.count > limit {
                        _ = aggregatedResults.popMin()
                    }
                }
            }
            return aggregatedResults
        }
 */
    }
hassila commented 1 week ago

Ok, reduced it a bit further (unfortunately large dependencies on our internal stuff so can't share a standalone reproducer).

The following observation:

extension OrdoObjectCache where OrdoObject == OrdoPublic.Instrument {
    public func okSearch(for string: String) -> OrdoObject? {
        ordoObjects.entriesSnapshot { sequence in
        }
        return nil
    }
}

extension OrdoObjectCache {
    public func crashSearch(for string: String) -> OrdoObject? {
        ordoObjects.entriesSnapshot { sequence in
        }
        return nil
    }
}

So accessing entriesSnapshot in the generic unconstrained extension above, will crash - while the one that is constrained to OrdoPublic.Instrument will work ok.

hassila commented 1 week ago

Ok, we have a minimised test case now that crashes:

protocol Cache<Object> {
    associatedtype Object
    associatedtype Snapshot: Sequence<Object>

    func entries(_ body: (Snapshot) -> Void) -> AsyncStream<Object>
}

func readFromCacheImpl<T>(cache: any Cache<T>) async {
    let updateStream = cache.entries { _ in }

    for await _ in updateStream {}
}

To reproduce:

hassila@min ~/g/p/Pivot (main)> cat > a.swift
protocol Cache<Object> {
    associatedtype Object
    associatedtype Snapshot: Sequence<Object>

    func entries(_ body: (Snapshot) -> Void) -> AsyncStream<Object>
}

func readFromCacheImpl<T>(cache: any Cache<T>) async {
    let updateStream = cache.entries { _ in }

    for await _ in updateStream {}
}
hassila@min ~/g/p/Pivot (main)> swiftc a.swift 
error: compile command failed due to signal 5 (use -v to see invocation)
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.  Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -c -primary-file a.swift -target arm64-apple-macosx14.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -stack-check -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk -color-diagnostics -new-driver-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-driver -empty-abi-descriptor -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift -module-name a -disable-clang-spi -target-sdk-version 14.5 -target-sdk-name macosx14.5 -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/local/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/local/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/local/lib/swift/host/plugins -o /var/folders/p2/yd6nfr2s5dlg2z2c9rbfc_040000gv/T/TemporaryDirectory.D0GVlR/a-1.o
1.  Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
2.  Compiling with the current language version
3.  While evaluating request ASTLoweringRequest(Lowering AST to SIL for file "a.swift")
4.  While silgen emitFunction SIL function "@$s1a17readFromCacheImpl5cacheyAA0C0_px6ObjectRts_XP_tYalF".
 for 'readFromCacheImpl(cache:)' (at a.swift:8:1)
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           0x0000000106873f3c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x00000001068730f8 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x0000000106874544 SignalHandler(int) + 360
3  libsystem_platform.dylib 0x00000001a0003584 _sigtramp + 56
4  swift-frontend           0x0000000102866ab0 swift::Mangle::ASTMangler::appendRequirement(swift::Requirement const&, swift::GenericSignature, bool) + 140
5  swift-frontend           0x0000000102866ab0 swift::Mangle::ASTMangler::appendRequirement(swift::Requirement const&, swift::GenericSignature, bool) + 140
6  swift-frontend           0x0000000102859c74 swift::Mangle::ASTMangler::appendGenericSignature(swift::GenericSignature, swift::GenericSignature) + 884
7  swift-frontend           0x000000010285bd94 swift::Mangle::ASTMangler::mangleReabstractionThunkHelper(swift::CanTypeWrapper<swift::SILFunctionType>, swift::Type, swift::Type, swift::Type, swift::Type, swift::ModuleDecl*) + 204
8  swift-frontend           0x00000001018b1064 swift::Lowering::SILGenModule::getOrCreateReabstractionThunk(swift::CanTypeWrapper<swift::SILFunctionType>, swift::CanTypeWrapper<swift::SILFunctionType>, swift::CanTypeWrapper<swift::SILFunctionType>, swift::CanType, swift::CanType) + 1076
9  swift-frontend           0x000000010188bf70 createThunk(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::Lowering::ManagedValue, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::Lowering::TypeLowering const&) + 3344
10 swift-frontend           0x000000010188251c (anonymous namespace)::Transform::transform(swift::Lowering::ManagedValue, swift::Lowering::AbstractionPattern, swift::CanType, swift::Lowering::AbstractionPattern, swift::CanType, swift::SILType, swift::Lowering::SGFContext) + 1500
11 swift-frontend           0x0000000101881f20 swift::Lowering::SILGenFunction::emitTransformedValue(swift::SILLocation, swift::Lowering::ManagedValue, swift::CanType, swift::CanType, swift::Lowering::SGFContext) + 344
12 swift-frontend           0x00000001017b7b14 (anonymous namespace)::DelayedArgument::finishOriginalExpr(swift::Lowering::SILGenFunction&, swift::Expr*) + 1212
13 swift-frontend           0x00000001017b6f1c (anonymous namespace)::DelayedArgument::emit(swift::Lowering::SILGenFunction&, llvm::SmallVectorImpl<swift::Lowering::ManagedValue>&, unsigned long&) + 104
14 swift-frontend           0x00000001017a13c0 emitDelayedArguments(swift::Lowering::SILGenFunction&, llvm::MutableArrayRef<(anonymous namespace)::DelayedArgument>, llvm::MutableArrayRef<llvm::SmallVector<swift::Lowering::ManagedValue, 4u>>) + 424
15 swift-frontend           0x00000001017bda04 (anonymous namespace)::CallEmission::emitArgumentsForNormalApply(swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::SILFunctionType>, swift::ForeignInfo const&, llvm::SmallVectorImpl<swift::Lowering::ManagedValue>&, llvm::Optional<swift::SILLocation>&) + 1056
16 swift-frontend           0x00000001017a5d68 (anonymous namespace)::CallEmission::apply(swift::Lowering::SGFContext) + 4064
17 swift-frontend           0x00000001017a37bc swift::Lowering::SILGenFunction::emitApplyExpr(swift::ApplyExpr*, swift::Lowering::SGFContext) + 3060
18 swift-frontend           0x0000000101833eb8 void llvm::function_ref<void (swift::Expr*)>::callback_fn<swift::Lowering::RValue swift::Lowering::SILGenFunction::emitOpenExistentialExpr<swift::Lowering::RValue, (anonymous namespace)::RValueEmitter::visitOpenExistentialExpr(swift::OpenExistentialExpr*, swift::Lowering::SGFContext)::$_18>(swift::OpenExistentialExpr*, (anonymous namespace)::RValueEmitter::visitOpenExistentialExpr(swift::OpenExistentialExpr*, swift::Lowering::SGFContext)::$_18)::'lambda'(swift::Expr*)>(long, swift::Expr*) + 36
19 swift-frontend           0x0000000101818b48 swift::Lowering::SILGenFunction::emitOpenExistentialExprImpl(swift::OpenExistentialExpr*, llvm::function_ref<void (swift::Expr*)>) + 812
20 swift-frontend           0x00000001018251b0 (anonymous namespace)::RValueEmitter::visitOpenExistentialExpr(swift::OpenExistentialExpr*, swift::Lowering::SGFContext) + 272
21 swift-frontend           0x000000010180c2cc swift::Lowering::SILGenFunction::emitExprInto(swift::Expr*, swift::Lowering::Initialization*, llvm::Optional<swift::SILLocation>) + 128
22 swift-frontend           0x00000001017f6f68 swift::Lowering::SILGenFunction::emitPatternBinding(swift::PatternBindingDecl*, unsigned int, bool) + 1980
23 swift-frontend           0x00000001017fd92c swift::ASTVisitor<swift::Lowering::SILGenFunction, void, void, void, void, void, void>::visit(swift::Decl*) + 140
24 swift-frontend           0x00000001018a75f4 swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 4888
25 swift-frontend           0x000000010183e538 swift::Lowering::SILGenFunction::emitFunction(swift::FuncDecl*) + 632
26 swift-frontend           0x0000000101792e48 swift::Lowering::SILGenModule::emitFunctionDefinition(swift::SILDeclRef, swift::SILFunction*) + 8344
27 swift-frontend           0x00000001017935bc swift::Lowering::SILGenModule::emitOrDelayFunction(swift::SILDeclRef) + 172
28 swift-frontend           0x0000000101790d9c swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) + 292
29 swift-frontend           0x0000000101796b54 swift::ASTLoweringRequest::evaluate(swift::Evaluator&, swift::ASTLoweringDescriptor) const + 1668
30 swift-frontend           0x00000001018a5f1c 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&) + 196
31 swift-frontend           0x0000000101799f44 llvm::Expected<swift::ASTLoweringRequest::OutputType> swift::Evaluator::getResultUncached<swift::ASTLoweringRequest>(swift::ASTLoweringRequest const&) + 584
32 swift-frontend           0x0000000101171408 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 548
33 swift-frontend           0x0000000101175694 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1448
34 swift-frontend           0x00000001011736d0 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 4968
35 swift-frontend           0x0000000101102e8c swift::mainEntry(int, char const**) + 2612
36 dyld                     0x000000019fc4a0e0 start + 2360
error: fatalError