swiftlang / swift

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

[6.0.1] Compiler crashes for code that was compiling in Swift 6.0 #76741

Open soumyamahunt opened 1 month ago

soumyamahunt commented 1 month ago

Description

If I try to compile Swift package: https://github.com/SwiftyLab/MetaCodable with Swift 6.0 toolchain package is built without errors. When trying to compile with Swift 6.0.1 following compiler crash occurs:

Reproduction

Try to build swift package: https://github.com/SwiftyLab/MetaCodable with latest Swift 6.0.1 toolchain on macOS 14.

Stack dump

0  swift-frontend           0x0000000108029b78 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x0000000108028344 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x000000010802a1c0 SignalHandler(int) + 304
3  libsystem_platform.dylib 0x000000018e34e584 _sigtramp + 56
4  libsystem_pthread.dylib  0x000000018e31dc20 pthread_kill + 288
5  libsystem_c.dylib        0x000000018e22aa30 abort + 180
6  swift-frontend           0x0000000108582c28 swift::rewriting::RequirementMachine::verify(swift::rewriting::MutableTerm const&) const (.cold.3) + 0
7  swift-frontend           0x000000010442f158 swift::rewriting::RequirementMachine::verify(swift::rewriting::MutableTerm const&) const + 1016
8  swift-frontend           0x000000010442f5f0 swift::rewriting::RequirementMachine::getRequiredProtocols(swift::Type) const + 136
9  swift-frontend           0x0000000102eec31c swift::irgen::FulfillmentMap::searchWitnessTable(swift::irgen::IRGenModule&, swift::CanType, swift::ProtocolDecl*, unsigned int, swift::irgen::MetadataPath&&, swift::irgen::FulfillmentMap::InterestingKeysCallback const&) + 216
10 swift-frontend           0x0000000102eebd14 swift::irgen::FulfillmentMap::searchNominalTypeMetadata(swift::irgen::IRGenModule&, swift::CanType, swift::MetadataState, unsigned int, swift::irgen::MetadataPath&&, swift::irgen::FulfillmentMap::InterestingKeysCallback const&) + 1200
11 swift-frontend           0x000000010301f954 (anonymous namespace)::PolymorphicConvention::considerWitnessSelf(swift::CanTypeWrapper<swift::SILFunctionType>) + 328
12 swift-frontend           0x000000010301f624 (anonymous namespace)::PolymorphicConvention::PolymorphicConvention(swift::irgen::IRGenModule&, swift::CanTypeWrapper<swift::SILFunctionType>, bool) + 304
13 swift-frontend           0x000000010301e018 swift::irgen::expandPolymorphicSignature(swift::irgen::IRGenModule&, swift::CanTypeWrapper<swift::SILFunctionType>, llvm::SmallVectorImpl<llvm::Type*>&, llvm::SmallVectorImpl<swift::irgen::PolymorphicSignatureExpandedTypeSource>*) + 68
14 swift-frontend           0x0000000102efd6a8 swift::irgen::(anonymous namespace)::SignatureExpansion::expandFunctionType(swift::irgen::SignatureExpansionABIDetails*) + 2672
15 swift-frontend           0x0000000102efcbc0 swift::irgen::Signature::getUncached(swift::irgen::IRGenModule&, swift::CanTypeWrapper<swift::SILFunctionType>, swift::irgen::FunctionPointerKind, bool, clang::CXXConstructorDecl const*) + 184
16 swift-frontend           0x0000000102fb6610 (anonymous namespace)::FuncSignatureInfo::getSignature(swift::irgen::IRGenModule&) const + 164
17 swift-frontend           0x0000000102fb6198 swift::irgen::IRGenModule::getSignature(swift::CanTypeWrapper<swift::SILFunctionType>, swift::irgen::FunctionPointerKind, bool, clang::CXXConstructorDecl const*) + 408
18 swift-frontend           0x0000000102f610a4 swift::irgen::IRGenModule::getAddrOfSILFunction(swift::SILFunction*, swift::ForDefinition_t, bool, bool) + 1428
19 swift-frontend           0x000000010302346c (anonymous namespace)::FragileWitnessTableBuilder::addMethod(swift::SILDeclRef) + 352
20 swift-frontend           0x0000000103022174 swift::SILWitnessVisitor<(anonymous namespace)::FragileWitnessTableBuilder>::visitProtocolDecl(swift::ProtocolDecl*) + 2176
21 swift-frontend           0x0000000103018f18 swift::irgen::IRGenModule::emitSILWitnessTable(swift::SILWitnessTable*) + 1652
22 swift-frontend           0x0000000102f5c360 swift::irgen::IRGenerator::emitGlobalTopLevel(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&) + 884
23 swift-frontend           0x000000010306e124 swift::IRGenRequest::evaluate(swift::Evaluator&, swift::IRGenDescriptor) const + 2172
24 swift-frontend           0x00000001030bafc8 swift::GeneratedModule swift::SimpleRequest<swift::IRGenRequest, swift::GeneratedModule (swift::IRGenDescriptor), (swift::RequestFlags)9>::callDerived<0ul>(swift::Evaluator&, std::__1::integer_sequence<unsigned long, 0ul>) const + 200
25 swift-frontend           0x00000001030767e0 swift::IRGenRequest::OutputType swift::Evaluator::getResultUncached<swift::IRGenRequest, swift::IRGenRequest::OutputType swift::evaluateOrFatal<swift::IRGenRequest>(swift::Evaluator&, swift::IRGenRequest)::'lambda'()>(swift::IRGenRequest const&, swift::IRGenRequest::OutputType swift::evaluateOrFatal<swift::IRGenRequest>(swift::Evaluator&, swift::IRGenRequest)::'lambda'()) + 212
26 swift-frontend           0x000000010307018c swift::performIRGeneration(swift::FileUnit*, swift::IRGenOptions const&, swift::TBDGenOptions const&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::StringRef, llvm::GlobalVariable**) + 208
27 swift-frontend           0x0000000102b7a564 generateIR(swift::IRGenOptions const&, swift::TBDGenOptions const&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>, swift::PrimarySpecificPaths const&, llvm::StringRef, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, llvm::GlobalVariable*&, llvm::ArrayRef<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>) + 156
28 swift-frontend           0x0000000102b76f98 performCompileStepsPostSILGen(swift::CompilerInstance&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*) + 1416
29 swift-frontend           0x0000000102b763f8 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 656
30 swift-frontend           0x0000000102b82104 withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) + 160
31 swift-frontend           0x0000000102b782d0 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 708
32 swift-frontend           0x0000000102b779a4 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2344
33 swift-frontend           0x000000010298dfdc swift::mainEntry(int, char const**) + 3096
34 dyld                     0x000000018df93154 start + 2476

Expected behavior

Code should compile.

Environment

Apple Swift version 6.0.1 (swift-6.0.1-RELEASE) Target: arm64-apple-macosx10.15

Host: macOS 14.6.1 arm64

Additional information

1.  Apple Swift version 6.0.1 (swift-6.0.1-RELEASE)
2.  Compiling with effective version 5.10
3.  While evaluating request IRGenRequest(IR Generation for file "/Users/runner/work/MetaCodable/MetaCodable/Sources/PluginCore/Variables/Type/MemberGroup.swift")
4.  While emitting witness table for protocol conformance MemberGroup<Decl>: DeclaredVariable at extension of MemberGroup (at /Users/runner/work/MetaCodable/MetaCodable/Sources/PluginCore/Variables/Type/MemberGroup.swift:160: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           0x0000000108029b78 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x0000000108028344 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x000000010802a1c0 SignalHandler(int) + 304
3  libsystem_platform.dylib 0x000000018e34e584 _sigtramp + 56
4  libsystem_pthread.dylib  0x000000018e31dc20 pthread_kill + 288
5  libsystem_c.dylib        0x000000018e22aa30 abort + 180
6  swift-frontend           0x0000000108582c28 swift::rewriting::RequirementMachine::verify(swift::rewriting::MutableTerm const&) const (.cold.3) + 0
7  swift-frontend           0x000000010442f158 swift::rewriting::RequirementMachine::verify(swift::rewriting::MutableTerm const&) const + 1016
8  swift-frontend           0x000000010442f5f0 swift::rewriting::RequirementMachine::getRequiredProtocols(swift::Type) const + 136
9  swift-frontend           0x0000000102eec31c swift::irgen::FulfillmentMap::searchWitnessTable(swift::irgen::IRGenModule&, swift::CanType, swift::ProtocolDecl*, unsigned int, swift::irgen::MetadataPath&&, swift::irgen::FulfillmentMap::InterestingKeysCallback const&) + 216
10 swift-frontend           0x0000000102eebd14 swift::irgen::FulfillmentMap::searchNominalTypeMetadata(swift::irgen::IRGenModule&, swift::CanType, swift::MetadataState, unsigned int, swift::irgen::MetadataPath&&, swift::irgen::FulfillmentMap::InterestingKeysCallback const&) + 1200
11 swift-frontend           0x000000010301f954 (anonymous namespace)::PolymorphicConvention::considerWitnessSelf(swift::CanTypeWrapper<swift::SILFunctionType>) + 328
12 swift-frontend           0x000000010301f624 (anonymous namespace)::PolymorphicConvention::PolymorphicConvention(swift::irgen::IRGenModule&, swift::CanTypeWrapper<swift::SILFunctionType>, bool) + 304
13 swift-frontend           0x000000010301e018 swift::irgen::expandPolymorphicSignature(swift::irgen::IRGenModule&, swift::CanTypeWrapper<swift::SILFunctionType>, llvm::SmallVectorImpl<llvm::Type*>&, llvm::SmallVectorImpl<swift::irgen::PolymorphicSignatureExpandedTypeSource>*) + 68
14 swift-frontend           0x0000000102efd6a8 swift::irgen::(anonymous namespace)::SignatureExpansion::expandFunctionType(swift::irgen::SignatureExpansionABIDetails*) + 2672
15 swift-frontend           0x0000000102efcbc0 swift::irgen::Signature::getUncached(swift::irgen::IRGenModule&, swift::CanTypeWrapper<swift::SILFunctionType>, swift::irgen::FunctionPointerKind, bool, clang::CXXConstructorDecl const*) + 184
16 swift-frontend           0x0000000102fb6610 (anonymous namespace)::FuncSignatureInfo::getSignature(swift::irgen::IRGenModule&) const + 164
17 swift-frontend           0x0000000102fb6198 swift::irgen::IRGenModule::getSignature(swift::CanTypeWrapper<swift::SILFunctionType>, swift::irgen::FunctionPointerKind, bool, clang::CXXConstructorDecl const*) + 408
18 swift-frontend           0x0000000102f610a4 swift::irgen::IRGenModule::getAddrOfSILFunction(swift::SILFunction*, swift::ForDefinition_t, bool, bool) + 1428
19 swift-frontend           0x000000010302346c (anonymous namespace)::FragileWitnessTableBuilder::addMethod(swift::SILDeclRef) + 352
20 swift-frontend           0x0000000103022174 swift::SILWitnessVisitor<(anonymous namespace)::FragileWitnessTableBuilder>::visitProtocolDecl(swift::ProtocolDecl*) + 2176
21 swift-frontend           0x0000000103018f18 swift::irgen::IRGenModule::emitSILWitnessTable(swift::SILWitnessTable*) + 1652
22 swift-frontend           0x0000000102f5c360 swift::irgen::IRGenerator::emitGlobalTopLevel(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&) + 884
23 swift-frontend           0x000000010306e124 swift::IRGenRequest::evaluate(swift::Evaluator&, swift::IRGenDescriptor) const + 2172
24 swift-frontend           0x00000001030bafc8 swift::GeneratedModule swift::SimpleRequest<swift::IRGenRequest, swift::GeneratedModule (swift::IRGenDescriptor), (swift::RequestFlags)9>::callDerived<0ul>(swift::Evaluator&, std::__1::integer_sequence<unsigned long, 0ul>) const + 200
25 swift-frontend           0x00000001030767e0 swift::IRGenRequest::OutputType swift::Evaluator::getResultUncached<swift::IRGenRequest, swift::IRGenRequest::OutputType swift::evaluateOrFatal<swift::IRGenRequest>(swift::Evaluator&, swift::IRGenRequest)::'lambda'()>(swift::IRGenRequest const&, swift::IRGenRequest::OutputType swift::evaluateOrFatal<swift::IRGenRequest>(swift::Evaluator&, swift::IRGenRequest)::'lambda'()) + 212
26 swift-frontend           0x000000010307018c swift::performIRGeneration(swift::FileUnit*, swift::IRGenOptions const&, swift::TBDGenOptions const&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::StringRef, llvm::GlobalVariable**) + 208
27 swift-frontend           0x0000000102b7a564 generateIR(swift::IRGenOptions const&, swift::TBDGenOptions const&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>, swift::PrimarySpecificPaths const&, llvm::StringRef, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, llvm::GlobalVariable*&, llvm::ArrayRef<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>) + 156
28 swift-frontend           0x0000000102b76f98 performCompileStepsPostSILGen(swift::CompilerInstance&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*) + 1416
29 swift-frontend           0x0000000102b763f8 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 656
30 swift-frontend           0x0000000102b82104 withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) + 160
31 swift-frontend           0x0000000102b782d0 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 708
32 swift-frontend           0x0000000102b779a4 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2344
33 swift-frontend           0x000000010298dfdc swift::mainEntry(int, char const**) + 3096
34 dyld                     0x000000018df93154 start + 2476
Apple Swift version 6.0.1 (swift-6.0.1-RELEASE)
Target: arm64-apple-macosx10.15

The complete build log can be sheen as part of GitHub workflow run: https://github.com/SwiftyLab/MetaCodable/actions/runs/11062444941/job/30736942223