swiftlang / swift

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

Expanding a closure's type parameter pack into a tuple of metatypes can crash #71576

Open slice opened 4 months ago

slice commented 4 months ago

Description

Performing a pack expansion on a type parameter pack present within a closure's parameters in order to materialize a tuple of its metatypes sometimes crashes the compiler. Compilation can succeed and print (DiscordLib2CrashingSometimes.T, DiscordLib2CrashingSometimes.T), or crash and result in two distinct backtraces. (There can potentially be more, but I have personally only observed two.)

Also, I should note that I have no idea whether this code is actually "supposed" to compile or not—I ran into the crash while experimentally designing an API that uses parameter packs. Assuming that it'd be necessary to conditionalize code at runtime depending on the types in the pack, I instinctually reached for metatypes. I think what I'm aiming to achieve likely won't require this, though, but I haven't sorted all of the details just yet.

Reproduction

protocol Protocol {}
struct T: Protocol {}

struct Command<each A: Protocol> {
    let arguments: (repeat (each A).Type)
}

func command<each A: Protocol>(_ handler: (_ arg: repeat each A) -> Void) -> Command<repeat each A> {
    return Command(arguments: (repeat (each A).self))
}

let myCommand = command { (first: T, second: T) in () }
print(myCommand.arguments)

Stack dump

[!WARNING] This is only one of the stack dumps I observed with this code; the other is linked below.

Stack dump:
0.  Program arguments: /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-02-11-a.xctoolchain/usr/bin/swift-frontend -frontend -interpret DiscordLib2CrashingSometimes.swift -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -empty-abi-descriptor -resource-dir /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-02-11-a.xctoolchain/usr/lib/swift -module-name DiscordLib2CrashingSometimes -target-sdk-version 14.2 -target-sdk-name macosx14.2 -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/local/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.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-DEVELOPMENT-SNAPSHOT-2024-02-11-a.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-02-11-a.xctoolchain/usr/local/lib/swift/host/plugins
1.  Apple Swift version 5.11-dev (LLVM 1bcf1d71b715d0d, Swift 009a93a0f83dd5c)
2.  Compiling with the current language version
3.  While evaluating request ASTLoweringRequest(Lowering AST to SIL for module DiscordLib2CrashingSometimes)
 #0 0x00000001087867f8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/llvm-project/llvm/lib/Support/Unix/Signals.inc:610:8
 #1 0x0000000108784ce5 llvm::sys::RunSignalHandlers() /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/llvm-project/llvm/lib/Support/Signals.cpp:105:18
 #2 0x0000000108786e4e SignalHandler(int) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/llvm-project/llvm/lib/Support/Unix/Signals.inc:413:1
 #3 0x00007ff80da6937d (/usr/lib/system/libsystem_platform.dylib+0x7ff80046937d)
 #4 0x0000000000000000 
 #5 0x00000001035e703a swift::Type::Type(swift::TypeBase*) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/include/swift/AST/Type.h:248:40
 #6 0x00000001035e703a swift::CanType::CanType(swift::TypeBase*) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/include/swift/AST/Type.h:447:39
 #7 0x00000001035e703a swift::CanType::CanType(swift::TypeBase*) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/include/swift/AST/Type.h:447:47
 #8 0x00000001035e703a swift::Lowering::AbstractionPattern::AbstractionPattern(swift::SubstitutionMap, swift::CanGenericSignature, swift::CanType) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/include/swift/SIL/AbstractionPattern.h:588:12
 #9 0x00000001035e703a swift::Lowering::AbstractionPattern::AbstractionPattern(swift::SubstitutionMap, swift::CanGenericSignature, swift::CanType) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/include/swift/SIL/AbstractionPattern.h:589:49
#10 0x00000001035e703a swift::Lowering::AbstractionPattern::getTupleElementType(unsigned int) const /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SIL/IR/AbstractionPattern.cpp:420:12
#11 0x0000000102dfa9de swift::TupleType::getElementType(unsigned int) const /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/include/swift/AST/Types.h:2539:12
#12 0x0000000102dfa9de swift::CanTypeWrapper<swift::TupleType>::getElementType(unsigned int) const /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/include/swift/AST/Types.h:2574:34
#13 0x0000000102dfa9de (anonymous namespace)::Transform::transform(swift::Lowering::RValue&&, swift::Lowering::AbstractionPattern, swift::CanType, swift::Lowering::AbstractionPattern, swift::CanType, swift::SILType, swift::Lowering::SGFContext) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/SILGenPoly.cpp:361:49
#14 0x0000000102df7782 swift::Lowering::SILGenFunction::emitOrigToSubstValue(swift::SILLocation, swift::Lowering::RValue&&, swift::Lowering::AbstractionPattern, swift::CanType, swift::Lowering::SGFContext) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/SILGenPoly.cpp:6424:3
#15 0x0000000102dcafba (anonymous namespace)::OrigToSubstComponent::translate(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::Lowering::RValue&&, swift::Lowering::SGFContext) && /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/SILGenLValue.cpp:2619:7
#16 0x0000000102dba4a4 std::__1::vector<swift::Lowering::ManagedValue, std::__1::allocator<swift::Lowering::ManagedValue> >::__destroy_vector::operator()[abi:v160006]() /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/vector:445:22
#17 0x0000000102dba4a4 std::__1::vector<swift::Lowering::ManagedValue, std::__1::allocator<swift::Lowering::ManagedValue> >::~vector[abi:v160006]() /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/vector:456:67
#18 0x0000000102dba4a4 std::__1::vector<swift::Lowering::ManagedValue, std::__1::allocator<swift::Lowering::ManagedValue> >::~vector[abi:v160006]() /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/vector:456:65
#19 0x0000000102dba4a4 swift::Lowering::RValue::~RValue() /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/RValue.h:72:7
#20 0x0000000102dba4a4 swift::Lowering::RValue::~RValue() /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/RValue.h:72:7
#21 0x0000000102dba4a4 swift::Lowering::TranslationPathComponent::get(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::Lowering::ManagedValue, swift::Lowering::SGFContext) && /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/SILGenLValue.cpp:2580:1
#22 0x0000000102dc01fa swift::Lowering::RValue::isComplete() const & /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/RValue.h:202:38
#23 0x0000000102dc01fa swift::Lowering::RValue::operator=(swift::Lowering::RValue&&) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/RValue.h:146:5
#24 0x0000000102dc01fa swift::Lowering::SILGenFunction::emitLoadOfLValue(swift::SILLocation, swift::Lowering::LValue&&, swift::Lowering::SGFContext, bool) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/SILGenLValue.cpp:5110:14
#25 0x0000000102d91095 std::__1::vector<std::__1::unique_ptr<swift::Lowering::PathComponent, std::__1::default_delete<swift::Lowering::PathComponent> >, std::__1::allocator<std::__1::unique_ptr<swift::Lowering::PathComponent, std::__1::default_delete<swift::Lowering::PathComponent> > > >::__destroy_vector::operator()[abi:v160006]() /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/vector:445:22
#26 0x0000000102d91095 std::__1::vector<std::__1::unique_ptr<swift::Lowering::PathComponent, std::__1::default_delete<swift::Lowering::PathComponent> >, std::__1::allocator<std::__1::unique_ptr<swift::Lowering::PathComponent, std::__1::default_delete<swift::Lowering::PathComponent> > > >::~vector[abi:v160006]() /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/vector:456:67
#27 0x0000000102d91095 std::__1::vector<std::__1::unique_ptr<swift::Lowering::PathComponent, std::__1::default_delete<swift::Lowering::PathComponent> >, std::__1::allocator<std::__1::unique_ptr<swift::Lowering::PathComponent, std::__1::default_delete<swift::Lowering::PathComponent> > > >::~vector[abi:v160006]() /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/vector:456:65
#28 0x0000000102d91095 swift::Lowering::LValue::~LValue() /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/LValue.h:357:7
#29 0x0000000102d91095 swift::Lowering::LValue::~LValue() /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/LValue.h:357:7
#30 0x0000000102d91095 (anonymous namespace)::RValueEmitter::visitMemberRefExpr(swift::MemberRefExpr*, swift::Lowering::SGFContext) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/SILGenExpr.cpp:2573:1
#31 0x0000000102d8cd44 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/include/swift/AST/ExprNodes.def:0:3
#32 0x0000000102d822ec swift::Lowering::SILGenFunction::emitRValue(swift::Expr*, swift::Lowering::SGFContext) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/SILGenExpr.cpp:0:31
#33 0x0000000102d822ec swift::Lowering::SILGenFunction::emitRValueAsSingleValue(swift::Expr*, swift::Lowering::SGFContext) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/SILGenExpr.cpp:6720:10
#34 0x0000000102df7cc7 swift::Lowering::SILGenFunction::emitRValueAsOrig(swift::Expr*, swift::Lowering::AbstractionPattern, swift::Lowering::TypeLowering const&, swift::Lowering::SGFContext) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/SILGenPoly.cpp:0:23
#35 0x0000000102da1bc7 swift::Lowering::ManagedValue llvm::function_ref<swift::Lowering::ManagedValue (swift::Lowering::SGFContext)>::callback_fn<(anonymous namespace)::RValueEmitter::visitErasureExpr(swift::ErasureExpr*, swift::Lowering::SGFContext)::$_11>(long, swift::Lowering::SGFContext) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:5
#36 0x0000000102d67569 swift::Lowering::SILGenFunction::emitExistentialErasure(swift::SILLocation, swift::CanType, swift::Lowering::TypeLowering const&, swift::Lowering::TypeLowering const&, llvm::ArrayRef<swift::ProtocolConformanceRef>, swift::Lowering::SGFContext, llvm::function_ref<swift::Lowering::ManagedValue (swift::Lowering::SGFContext)>, bool)::$_6::operator()(swift::SILValue) const /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/SILGenConvert.cpp:870:29
#37 0x0000000102d67569 void llvm::function_ref<void (swift::SILValue)>::callback_fn<swift::Lowering::SILGenFunction::emitExistentialErasure(swift::SILLocation, swift::CanType, swift::Lowering::TypeLowering const&, swift::Lowering::TypeLowering const&, llvm::ArrayRef<swift::ProtocolConformanceRef>, swift::Lowering::SGFContext, llvm::function_ref<swift::Lowering::ManagedValue (swift::Lowering::SGFContext)>, bool)::$_6>(long, swift::SILValue) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:12
#38 0x0000000102d493f2 swift::Lowering::SGFContext::getAddressForInPlaceInitialization(swift::Lowering::SILGenFunction&, swift::SILLocation) const /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/SGFContext.h:95:15
#39 0x0000000102d493f2 swift::Lowering::SILGenBuilder::bufferForExpr(swift::SILLocation, swift::SILType, swift::Lowering::TypeLowering const&, swift::Lowering::SGFContext, llvm::function_ref<void (swift::SILValue)>) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/SILGenBuilder.cpp:387:30
#40 0x0000000102d62d2e swift::Lowering::SILGenFunction::emitExistentialErasure(swift::SILLocation, swift::CanType, swift::Lowering::TypeLowering const&, swift::Lowering::TypeLowering const&, llvm::ArrayRef<swift::ProtocolConformanceRef>, swift::Lowering::SGFContext, llvm::function_ref<swift::Lowering::ManagedValue (swift::Lowering::SGFContext)>, bool) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/SILGenConvert.cpp:0:14
#41 0x0000000102d9875c (anonymous namespace)::RValueEmitter::visitErasureExpr(swift::ErasureExpr*, swift::Lowering::SGFContext) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/SILGenExpr.cpp:2149:25
#42 0x0000000102d8cf2b swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/include/swift/AST/ExprNodes.def:0:3
#43 0x0000000102d7f2fc swift::Lowering::RValue::isInContext() const & /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/RValue.h:211:57
#44 0x0000000102d7f2fc swift::Lowering::SILGenFunction::emitExprInto(swift::Expr*, swift::Lowering::Initialization*, std::__1::optional<swift::SILLocation>) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/SILGenExpr.cpp:413:14
#45 0x0000000102ce7f8b swift::Lowering::ArgumentSource::forwardInto(swift::Lowering::SILGenFunction&, swift::Lowering::Initialization*) && /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/ArgumentSource.cpp:125:1
#46 0x0000000102ce853b swift::Lowering::ArgumentSource::forwardInto(swift::Lowering::SILGenFunction&, swift::Lowering::AbstractionPattern, swift::Lowering::Initialization*, swift::Lowering::TypeLowering const&) && /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/ArgumentSource.cpp:0:22
#47 0x0000000102d9efd8 swift::Lowering::ArgumentSource::~ArgumentSource() /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/ArgumentSource.h:115:22
#48 0x0000000102d9efd8 swift::Lowering::ArgumentSource::~ArgumentSource() /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/ArgumentSource.h:114:21
#49 0x0000000102d9efd8 (anonymous namespace)::RValueEmitter::visitCollectionExpr(swift::CollectionExpr*, swift::Lowering::SGFContext) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/SILGenExpr.cpp:4445:5
#50 0x0000000102d8cc7c swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/include/swift/AST/ExprNodes.def:0:0
#51 0x0000000102d822ec swift::Lowering::SILGenFunction::emitRValue(swift::Expr*, swift::Lowering::SGFContext) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/SILGenExpr.cpp:0:31
#52 0x0000000102d822ec swift::Lowering::SILGenFunction::emitRValueAsSingleValue(swift::Expr*, swift::Lowering::SGFContext) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/SILGenExpr.cpp:6720:10
#53 0x0000000102d2a8a0 swift::isConsumedParameter(swift::ParameterConvention) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/include/swift/AST/Types.h:4096:3
#54 0x0000000102d2a8a0 swift::SILParameterInfo::isConsumed() const /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/include/swift/AST/Types.h:4243:12
#55 0x0000000102d2a8a0 (anonymous namespace)::ArgEmitter::emitDirect(swift::Lowering::ArgumentSource&&, swift::SILType, swift::Lowering::AbstractionPattern, swift::SILParameterInfo, std::__1::optional<swift::AnyFunctionType::Param>) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/SILGenApply.cpp:3855:18
#56 0x0000000102d2a8a0 (anonymous namespace)::ArgEmitter::emit(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern, std::__1::optional<swift::AnyFunctionType::Param>) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/SILGenApply.cpp:3546:5
#57 0x0000000102d17be4 (anonymous namespace)::ArgEmitter::emitSingleArg(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern, std::__1::optional<swift::AnyFunctionType::Param>) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/SILGenApply.cpp:3409:5
#58 0x0000000102d28b15 (anonymous namespace)::ArgEmitter::emitPreparedArgs(swift::Lowering::PreparedArguments&&, swift::Lowering::AbstractionPattern) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/SILGenApply.cpp:0:9
#59 0x0000000102d36643 (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&) && /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/SILGenApply.cpp:0:13
#60 0x0000000102d35d5e llvm::ArrayRef<swift::SILParameterInfo>::empty() const /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:160:40
#61 0x0000000102d35d5e (anonymous namespace)::ParamLowering::~ParamLowering() /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/SILGenApply.cpp:4691:5
#62 0x0000000102d35d5e (anonymous namespace)::ParamLowering::~ParamLowering() /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/SILGenApply.cpp:4690:20
#63 0x0000000102d35d5e (anonymous namespace)::CallEmission::emitArgumentsForNormalApply(swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::SILFunctionType>, swift::ForeignInfo const&, llvm::SmallVectorImpl<swift::Lowering::ManagedValue>&, std::__1::optional<swift::SILLocation>&) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/SILGenApply.cpp:5371:3
#64 0x0000000102d1bd25 (anonymous namespace)::CallEmission::applyNormalCall(swift::Lowering::SGFContext) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/SILGenApply.cpp:5097:26
#65 0x0000000102d1bd25 (anonymous namespace)::CallEmission::applyFirstLevelCallee(swift::Lowering::SGFContext) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/SILGenApply.cpp:5044:10
#66 0x0000000102d1bd25 (anonymous namespace)::CallEmission::apply(swift::Lowering::SGFContext) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/SILGenApply.cpp:4845:18
#67 0x0000000102d197f2 swift::Lowering::SILGenFunction::emitApplyExpr(swift::ApplyExpr*, swift::Lowering::SGFContext) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/SILGenApply.cpp:6144:1
#68 0x0000000102d8cc59 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/include/swift/AST/ExprNodes.def:0:0
#69 0x0000000102d82a0f std::__1::vector<swift::Lowering::ManagedValue, std::__1::allocator<swift::Lowering::ManagedValue> >::__destroy_vector::operator()[abi:v160006]() /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/vector:445:22
#70 0x0000000102d82a0f std::__1::vector<swift::Lowering::ManagedValue, std::__1::allocator<swift::Lowering::ManagedValue> >::~vector[abi:v160006]() /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/vector:456:67
#71 0x0000000102d82a0f std::__1::vector<swift::Lowering::ManagedValue, std::__1::allocator<swift::Lowering::ManagedValue> >::~vector[abi:v160006]() /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/vector:456:65
#72 0x0000000102d82a0f swift::Lowering::RValue::~RValue() /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/RValue.h:72:7
#73 0x0000000102d82a0f swift::Lowering::RValue::~RValue() /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/RValue.h:72:7
#74 0x0000000102d82a0f swift::Lowering::SILGenFunction::emitIgnoredExpr(swift::Expr*) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/SILGenExpr.cpp:6714:3
#75 0x0000000102e32ff3 swift::Lowering::SILGenTopLevel::visitTopLevelCodeDecl(swift::TopLevelCodeDecl*) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/SILGenTopLevel.cpp:0:11
#76 0x0000000102e3101b swift::Lowering::SILGenTopLevel::visitSourceFile(swift::SourceFile*) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/SILGenTopLevel.cpp:380:16
#77 0x0000000102e3053d swift::DiverseStackBase::stable_iterator::isValid() const /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/include/swift/Basic/DiverseStack.h:119:20
#78 0x0000000102e3053d swift::Lowering::Scope::~Scope() /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/Scope.h:78:15
#79 0x0000000102e3053d swift::Lowering::Scope::~Scope() /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/Scope.h:77:12
#80 0x0000000102e3053d swift::Lowering::SILGenModule::emitEntryPoint(swift::SourceFile*, swift::SILFunction*) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/SILGenTopLevel.cpp:88:3
#81 0x0000000102e327e1 swift::Lowering::SILGenModule::emitEntryPoint(swift::SourceFile*) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/SILGenTopLevel.cpp:0:3
#82 0x0000000102d090ce (anonymous namespace)::SILGenModuleRAII::emitSourceFile(swift::SourceFile*) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/SILGen.cpp:1991:11
#83 0x0000000102d090ce swift::ASTLoweringRequest::evaluate(swift::Evaluator&, swift::ASTLoweringDescriptor) const /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/SILGen.cpp:2142:13
#84 0x0000000102e1fe41 std::__1::__optional_destruct_base<llvm::SmallVector<swift::SymbolSource, 1u>, false>::~__optional_destruct_base[abi:v160006]() /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/optional:247:13
#85 0x0000000102e1fe41 std::__1::__optional_storage_base<llvm::SmallVector<swift::SymbolSource, 1u>, false>::~__optional_storage_base() /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/optional:322:8
#86 0x0000000102e1fe41 std::__1::__optional_copy_base<llvm::SmallVector<swift::SymbolSource, 1u>, false>::~__optional_copy_base() /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/optional:495:8
#87 0x0000000102e1fe41 std::__1::__optional_move_base<llvm::SmallVector<swift::SymbolSource, 1u>, false>::~__optional_move_base() /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/optional:523:8
#88 0x0000000102e1fe41 std::__1::__optional_copy_assign_base<llvm::SmallVector<swift::SymbolSource, 1u>, false>::~__optional_copy_assign_base() /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/optional:556:8
#89 0x0000000102e1fe41 std::__1::__optional_move_assign_base<llvm::SmallVector<swift::SymbolSource, 1u>, false>::~__optional_move_assign_base() /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/optional:588:8
#90 0x0000000102e1fe41 std::__1::optional<llvm::SmallVector<swift::SymbolSource, 1u> >::~optional() /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/optional:631:7
#91 0x0000000102e1fe41 std::__1::optional<llvm::SmallVector<swift::SymbolSource, 1u> >::~optional() /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/optional:631:7
#92 0x0000000102e1fe41 swift::ASTLoweringDescriptor::~ASTLoweringDescriptor() /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/include/swift/AST/SILGenRequests.h:50:8
#93 0x0000000102e1fe41 swift::ASTLoweringDescriptor::~ASTLoweringDescriptor() /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/include/swift/AST/SILGenRequests.h:50:8
#94 0x0000000102e1fe41 std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> > swift::SimpleRequest<swift::ASTLoweringRequest, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> > (swift::ASTLoweringDescriptor), (swift::RequestFlags)9>::callDerived<0ul>(swift::Evaluator&, std::__1::integer_sequence<unsigned long, 0ul>) const /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/include/swift/AST/SimpleRequest.h:267:5
#95 0x0000000102e1fe41 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&) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/include/swift/AST/SimpleRequest.h:290:20
#96 0x0000000102d0eda9 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'()) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/include/swift/AST/Evaluator.h:324:14
#97 0x0000000102d09a79 std::__1::__optional_destruct_base<llvm::SmallVector<swift::SymbolSource, 1u>, false>::~__optional_destruct_base[abi:v160006]() /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/optional:247:13
#98 0x0000000102d09a79 std::__1::__optional_storage_base<llvm::SmallVector<swift::SymbolSource, 1u>, false>::~__optional_storage_base() /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/optional:322:8
#99 0x0000000102d09a79 std::__1::__optional_copy_base<llvm::SmallVector<swift::SymbolSource, 1u>, false>::~__optional_copy_base() /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/optional:495:8
#100 0x0000000102d09a79 std::__1::__optional_move_base<llvm::SmallVector<swift::SymbolSource, 1u>, false>::~__optional_move_base() /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/optional:523:8
#101 0x0000000102d09a79 std::__1::__optional_copy_assign_base<llvm::SmallVector<swift::SymbolSource, 1u>, false>::~__optional_copy_assign_base() /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/optional:556:8
#102 0x0000000102d09a79 std::__1::__optional_move_assign_base<llvm::SmallVector<swift::SymbolSource, 1u>, false>::~__optional_move_assign_base() /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/optional:588:8
#103 0x0000000102d09a79 std::__1::optional<llvm::SmallVector<swift::SymbolSource, 1u> >::~optional() /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/optional:631:7
#104 0x0000000102d09a79 std::__1::optional<llvm::SmallVector<swift::SymbolSource, 1u> >::~optional() /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/optional:631:7
#105 0x0000000102d09a79 swift::ASTLoweringDescriptor::~ASTLoweringDescriptor() /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/include/swift/AST/SILGenRequests.h:50:8
#106 0x0000000102d09a79 swift::ASTLoweringDescriptor::~ASTLoweringDescriptor() /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/include/swift/AST/SILGenRequests.h:50:8
#107 0x0000000102d09a79 std::__1::__tuple_leaf<0ul, swift::ASTLoweringDescriptor, false>::~__tuple_leaf() /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/tuple:293:7
#108 0x0000000102d09a79 std::__1::__tuple_impl<std::__1::__tuple_indices<0ul>, swift::ASTLoweringDescriptor>::~__tuple_impl() /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/tuple:479:37
#109 0x0000000102d09a79 std::__1::__tuple_impl<std::__1::__tuple_indices<0ul>, swift::ASTLoweringDescriptor>::~__tuple_impl() /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/tuple:479:37
#110 0x0000000102d09a79 std::__1::tuple<swift::ASTLoweringDescriptor>::~tuple() /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/tuple:566:28
#111 0x0000000102d09a79 std::__1::tuple<swift::ASTLoweringDescriptor>::~tuple() /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/tuple:566:28
#112 0x0000000102d09a79 swift::SimpleRequest<swift::ASTLoweringRequest, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> > (swift::ASTLoweringDescriptor), (swift::RequestFlags)9>::~SimpleRequest() /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/include/swift/AST/SimpleRequest.h:252:7
#113 0x0000000102d09a79 swift::ASTLoweringRequest::~ASTLoweringRequest() /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/include/swift/AST/SILGenRequests.h:111:7
#114 0x0000000102d09a79 swift::ASTLoweringRequest::~ASTLoweringRequest() /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/include/swift/AST/SILGenRequests.h:111:7
#115 0x0000000102d09a79 swift::performASTLowering(swift::ModuleDecl*, swift::Lowering::TypeConverter&, swift::SILOptions const&, swift::IRGenOptions const*) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/SILGen/SILGen.cpp:2165:3
#116 0x000000010262a317 std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >::release[abi:v160006]() /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/__memory/unique_ptr.h:288:26
#117 0x000000010262a317 std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >::unique_ptr[abi:v160006](std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >&&) /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/__memory/unique_ptr.h:211:20
#118 0x000000010262a317 std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >::unique_ptr[abi:v160006](std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >&&) /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/__memory/unique_ptr.h:211:80
#119 0x000000010262a317 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/FrontendTool/FrontendTool.cpp:882:52
#120 0x000000010263d7cf withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/FrontendTool/FrontendTool.cpp:1304:25
#121 0x000000010262cc47 performAction(swift::CompilerInstance&, int&, swift::FrontendObserver*) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/FrontendTool/FrontendTool.cpp:0:12
#122 0x000000010262cc47 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/FrontendTool/FrontendTool.cpp:1515:19
#123 0x000000010262b96e swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/FrontendTool/FrontendTool.cpp:2470:19
#124 0x000000010244aecb run_driver(llvm::StringRef, llvm::ArrayRef<char const*>, llvm::ArrayRef<char const*>) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/DriverTool/driver.cpp:0:0
#125 0x000000010244aecb swift::mainEntry(int, char const**) /Users/ec2-user/jenkins/workspace/oss-swift-package-macos/swift/lib/DriverTool/driver.cpp:531:10
#126 0x0000000215fb2386

Expected behavior

I expect the code to print (DiscordLib2CrashingSometimes.T, DiscordLib2CrashingSometimes.T) all the time.

Environment

Apple Swift version 5.11-dev (LLVM 1bcf1d71b715d0d, Swift 009a93a0f83dd5c) Target: x86_64-apple-macosx14.0

Additional information

The stack dump provided is only one of the observed stack traces. Here is the other one: run_other.txt

Also, I noticed that by removing the second parameter in the code like this:

-let myCommand = command { (first: T, second: T) in () }
+let myCommand = command { (first: T) in () }

You get a different (albeit consistent, phew) compilation error. This might be a separate issue, but I figured I'd note it.

slice commented 4 months ago

Target: x86_64-apple-macosx14.0

I installed a trunk toolchain (with symbols) in an effort to build with the latest version of the compiler, but it's going through Rosetta (?) for some reason; I am on an Mac with Apple silicon.

The code still intermittently crashes (or suceeds) on the latest stable Xcode at the time of writing, but with (yet) another different stack dump. Luckily, there only seems to be one failure path here:

swift-driver version: 1.87.3 Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5) Target: arm64-apple-macosx14.0 Stack dump: run_swift592.txt

Again, it could be an unrelated or since-solved issue, but I figured I'd note it anyways.

AnthonyLatsis commented 4 months ago

No apparent non-determinism to the crash with a 8bb684628593220 compiler (although this still smells like a memory issue). Reduced example:

struct S<each A> {
  let metatypes: (repeat (each A).Type)

  init() {
    self.metatypes = (repeat (each A).self)
  }
}
let _ = S<Int, Bool>().metatypes
Stack dump:
0.  Program arguments: bin/swift-frontend -debug-diagnostic-names -interpret /Users/mac/Desktop/test.swift
1.  Swift version 5.11-dev (LLVM 87ace14daa2139a, Swift 8bb684628593220)
2.  Compiling with the current language version
3.  While evaluating request ASTLoweringRequest(Lowering AST to SIL for module test)
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           0x000000011586fad8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 40
1  swift-frontend           0x000000011586df25 llvm::sys::RunSignalHandlers() + 85
2  swift-frontend           0x000000011587012e SignalHandler(int) + 270
3  libsystem_platform.dylib 0x00007ff81bbae37d _sigtramp + 29
4  libsystem_platform.dylib 0x0000000000000001 _sigtramp + 18446603370115701921
5  swift-frontend           0x000000010ce50f4a swift::CanType::isActuallyCanonicalOrNull() const + 138
6  swift-frontend           0x000000010ce50e60 swift::CanType::CanType(swift::Type) + 32
7  swift-frontend           0x000000010ce50e2d swift::CanType::CanType(swift::Type) + 29
8  swift-frontend           0x000000010d5b81e4 swift::CanTypeWrapper<swift::TupleType>::getElementType(unsigned int) const + 52
9  swift-frontend           0x000000010ef58d86 getCanTupleElementType(swift::CanType, unsigned int) + 70
10 swift-frontend           0x000000010ef58af9 swift::Lowering::AbstractionPattern::getTupleElementType(unsigned int) const + 553
11 swift-frontend           0x000000010df4ada3 (anonymous namespace)::Transform::transform(swift::Lowering::RValue&&, swift::Lowering::AbstractionPattern, swift::CanType, swift::Lowering::AbstractionPattern, swift::CanType, swift::SILType, swift::Lowering::SGFContext) + 1875
12 swift-frontend           0x000000010df47947 swift::Lowering::SILGenFunction::emitTransformedValue(swift::SILLocation, swift::Lowering::RValue&&, swift::Lowering::AbstractionPattern, swift::CanType, swift::Lowering::AbstractionPattern, swift::CanType, swift::SILType, swift::Lowering::SGFContext) + 391
13 swift-frontend           0x000000010df4778e swift::Lowering::SILGenFunction::emitOrigToSubstValue(swift::SILLocation, swift::Lowering::RValue&&, swift::Lowering::AbstractionPattern, swift::CanType, swift::SILType, swift::Lowering::SGFContext) + 366
14 swift-frontend           0x000000010df475e8 swift::Lowering::SILGenFunction::emitOrigToSubstValue(swift::SILLocation, swift::Lowering::RValue&&, swift::Lowering::AbstractionPattern, swift::CanType, swift::Lowering::SGFContext) + 296
15 swift-frontend           0x000000010dee192a (anonymous namespace)::OrigToSubstComponent::translate(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::Lowering::RValue&&, swift::Lowering::SGFContext) && + 266
16 swift-frontend           0x000000010dec4a43 swift::Lowering::TranslationPathComponent::get(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::Lowering::ManagedValue, swift::Lowering::SGFContext) && + 227
17 swift-frontend           0x000000010decd55d swift::Lowering::SILGenFunction::emitLoadOfLValue(swift::SILLocation, swift::Lowering::LValue&&, swift::Lowering::SGFContext, bool) + 1757
18 swift-frontend           0x000000010de643e0 (anonymous namespace)::RValueEmitter::visitMemberRefExpr(swift::MemberRefExpr*, swift::Lowering::SGFContext) + 496
19 swift-frontend           0x000000010de53a90 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 976
20 swift-frontend           0x000000010de44271 swift::Lowering::SILGenFunction::emitRValue(swift::Expr*, swift::Lowering::SGFContext) + 209
21 swift-frontend           0x000000010de44075 swift::Lowering::SILGenFunction::emitExprInto(swift::Expr*, swift::Lowering::Initialization*, std::__1::optional<swift::SILLocation>) + 357
22 swift-frontend           0x000000010de0f51f swift::Lowering::SILGenFunction::emitPatternBinding(swift::PatternBindingDecl*, unsigned int, bool)::$_0::operator()(swift::Expr*, swift::VarDecl*, bool, std::__1::unique_ptr<swift::Lowering::Initialization, std::__1::default_delete<swift::Lowering::Initialization>>&) const + 671
23 swift-frontend           0x000000010de0ef09 swift::Lowering::SILGenFunction::emitPatternBinding(swift::PatternBindingDecl*, unsigned int, bool) + 1481
24 swift-frontend           0x000000010de0f5f6 swift::Lowering::SILGenFunction::visitPatternBindingDecl(swift::PatternBindingDecl*, bool) + 150
25 swift-frontend           0x000000010de244e2 swift::ASTVisitor<swift::Lowering::SILGenFunction, void, void, void, void, void, void>::visit(swift::Decl*) + 1522
26 swift-frontend           0x000000010dfba9ea swift::Lowering::SILGenTopLevel::visitTopLevelCodeDecl(swift::TopLevelCodeDecl*) + 714
27 swift-frontend           0x000000010dfba1ef swift::ASTVisitor<swift::Lowering::SILGenTopLevel, void, void, void, void, void, void>::visit(swift::Decl*) + 1391
28 swift-frontend           0x000000010dfb798d swift::Lowering::SILGenTopLevel::visitSourceFile(swift::SourceFile*) + 189
29 swift-frontend           0x000000010dfb6d68 swift::Lowering::SILGenModule::emitEntryPoint(swift::SourceFile*, swift::SILFunction*) + 1800
30 swift-frontend           0x000000010dfb999c swift::Lowering::SILGenModule::emitEntryPoint(swift::SourceFile*) + 316
31 swift-frontend           0x000000010dd394ab (anonymous namespace)::SILGenModuleRAII::emitSourceFile(swift::SourceFile*) + 91
32 swift-frontend           0x000000010dd3911e swift::ASTLoweringRequest::evaluate(swift::Evaluator&, swift::ASTLoweringDescriptor) const + 910
33 swift-frontend           0x000000010df96bae std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>> swift::SimpleRequest<swift::ASTLoweringRequest, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>> (swift::ASTLoweringDescriptor), (swift::RequestFlags)9>::callDerived<0ul>(swift::Evaluator&, std::__1::integer_sequence<unsigned long, 0ul>) const + 142
34 swift-frontend           0x000000010df96ac8 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&) + 40
35 swift-frontend           0x000000010dd56d0a llvm::Expected<swift::ASTLoweringRequest::OutputType> swift::Evaluator::getResultUncached<swift::ASTLoweringRequest>(swift::ASTLoweringRequest const&) + 330
36 swift-frontend           0x000000010dd39d88 llvm::Expected<swift::ASTLoweringRequest::OutputType> swift::Evaluator::operator()<swift::ASTLoweringRequest, (void*)0>(swift::ASTLoweringRequest const&) + 40
37 swift-frontend           0x000000010dd39c80 swift::performASTLowering(swift::ModuleDecl*, swift::Lowering::TypeConverter&, swift::SILOptions const&, swift::IRGenOptions const*) + 256
38 swift-frontend           0x000000010cfa040b swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 283
39 swift-frontend           0x000000010cfd1863 performAction(swift::CompilerInstance&, int&, swift::FrontendObserver*)::$_28::operator()(swift::CompilerInstance&) const + 147
40 swift-frontend           0x000000010cfd17bd bool llvm::function_ref<bool (swift::CompilerInstance&)>::callback_fn<performAction(swift::CompilerInstance&, int&, swift::FrontendObserver*)::$_28>(long, swift::CompilerInstance&) + 29
41 swift-frontend           0x000000010cfd0c81 llvm::function_ref<bool (swift::CompilerInstance&)>::operator()(swift::CompilerInstance&) const + 33
42 swift-frontend           0x000000010cfcfba8 withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) + 392
43 swift-frontend           0x000000010cfc8286 performAction(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1222
44 swift-frontend           0x000000010cfa38a6 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 262
45 swift-frontend           0x000000010cfa228f swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2783
46 swift-frontend           0x000000010ce4f9ff run_driver(llvm::StringRef, llvm::ArrayRef<char const*>, llvm::ArrayRef<char const*>) + 2431
47 swift-frontend           0x000000010ce4e627 swift::mainEntry(int, char const**) + 1543
48 swift-frontend           0x000000010ce4dbd2 main + 34
49 dyld                     0x00007ff81b7f83a6 start + 1942
Segmentation fault: 11
slice commented 3 months ago

Revisiting this with the Swift 5.10 toolchain shipping in Xcode 15.3 (15E204a), the compiler crashes seem to be non-determinate on my end with the original reproduction code:

2024_03_08-01-48-04-PM@2x

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

However, your minimized example crashes in a deterministic fashion.

Thanks for looking into this.