Open dnadoba opened 3 years ago
Attachment: Download
Issue Description:
If we deifine a protocol in Module A with a property defined as an extension
public protocol ProtocolFromModuleA {} public extension ProtocolFromModuleA { var propertyInExtension: Int { 0 } }
trying to create a key path to `propertyInExtension` in Module B crashes the compiler
import ModuleA func crash() { _ = \ProtocolFromModuleA.propertyInExtension // crashes }
Assertion failed: (genericSig && "Need a generic signature to resolve conformance"), function appendAnyProtocolConformance, file ASTMangler.cpp, line 3264. Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace. Stack dump: 0. Program arguments: /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2021-10-21-a.xctoolchain/usr/bin/swift-frontend -frontend -c -primary-file /Users/davidnadoba/Repositories/Playgrounds/KeyPathCompilerCrash/Sources/ModuleB/ModuleB.swift -emit-dependencies-path /Users/davidnadoba/Library/Developer/Xcode/DerivedData/KeyPathCompilerCrash-csatqcivyskzsgalxfvcvfmsfbhp/Build/Intermediates.noindex/KeyPathCompilerCrash.build/Debug/ModuleB.build/Objects-normal/x86_64/ModuleB.d -emit-reference-dependencies-path /Users/davidnadoba/Library/Developer/Xcode/DerivedData/KeyPathCompilerCrash-csatqcivyskzsgalxfvcvfmsfbhp/Build/Intermediates.noindex/KeyPathCompilerCrash.build/Debug/ModuleB.build/Objects-normal/x86_64/ModuleB.swiftdeps -serialize-diagnostics-path /Users/davidnadoba/Library/Developer/Xcode/DerivedData/KeyPathCompilerCrash-csatqcivyskzsgalxfvcvfmsfbhp/Build/Intermediates.noindex/KeyPathCompilerCrash.build/Debug/ModuleB.build/Objects-normal/x86_64/ModuleB.dia -target x86_64-apple-macos10.10 -enable-objc-interop -sdk "/Applications/Xcode SunriverEDogfood latest.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.4.sdk" -I /Users/davidnadoba/Library/Developer/Xcode/DerivedData/KeyPathCompilerCrash-csatqcivyskzsgalxfvcvfmsfbhp/Build/Products/Debug -I "/Applications/Xcode SunriverEDogfood latest.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib" -F /Users/davidnadoba/Library/Developer/Xcode/DerivedData/KeyPathCompilerCrash-csatqcivyskzsgalxfvcvfmsfbhp/Build/Products/Debug/PackageFrameworks -F /Users/davidnadoba/Library/Developer/Xcode/DerivedData/KeyPathCompilerCrash-csatqcivyskzsgalxfvcvfmsfbhp/Build/Products/Debug -F "/Applications/Xcode SunriverEDogfood latest.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks" -enable-testing -g -module-cache-path /Users/davidnadoba/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -swift-version 5 -enforce-exclusivity=checked -Onone -D SWIFT_PACKAGE -D DEBUG -D Xcode -new-driver-path /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2021-10-21-a.xctoolchain/usr/bin/swift-driver -serialize-debugging-options -resource-dir /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2021-10-21-a.xctoolchain/usr/lib/swift -enable-anonymous-context-mangled-names -Xcc -I/Users/davidnadoba/Library/Developer/Xcode/DerivedData/KeyPathCompilerCrash-csatqcivyskzsgalxfvcvfmsfbhp/Build/Intermediates.noindex/KeyPathCompilerCrash.build/Debug/ModuleB.build/swift-overrides.hmap -Xcc -I/Users/davidnadoba/Library/Developer/Xcode/DerivedData/KeyPathCompilerCrash-csatqcivyskzsgalxfvcvfmsfbhp/Build/Products/Debug/include -Xcc -I/Users/davidnadoba/Library/Developer/Xcode/DerivedData/KeyPathCompilerCrash-csatqcivyskzsgalxfvcvfmsfbhp/Build/Intermediates.noindex/KeyPathCompilerCrash.build/Debug/ModuleB.build/DerivedSources-normal/x86_64 -Xcc -I/Users/davidnadoba/Library/Developer/Xcode/DerivedData/KeyPathCompilerCrash-csatqcivyskzsgalxfvcvfmsfbhp/Build/Intermediates.noindex/KeyPathCompilerCrash.build/Debug/ModuleB.build/DerivedSources/x86_64 -Xcc -I/Users/davidnadoba/Library/Developer/Xcode/DerivedData/KeyPathCompilerCrash-csatqcivyskzsgalxfvcvfmsfbhp/Build/Intermediates.noindex/KeyPathCompilerCrash.build/Debug/ModuleB.build/DerivedSources -Xcc -DSWIFT_PACKAGE -Xcc -DDEBUG=1 -Xcc -working-directory/Users/davidnadoba/Repositories/Playgrounds/KeyPathCompilerCrash -module-name ModuleB -target-sdk-version 12.4.0 -parse-as-library -o /Users/davidnadoba/Library/Developer/Xcode/DerivedData/KeyPathCompilerCrash-csatqcivyskzsgalxfvcvfmsfbhp/Build/Intermediates.noindex/KeyPathCompilerCrash.build/Debug/ModuleB.build/Objects-normal/x86_64/ModuleB.o -index-store-path /Users/davidnadoba/Library/Developer/Xcode/DerivedData/KeyPathCompilerCrash-csatqcivyskzsgalxfvcvfmsfbhp/Index/DataStore -index-system-modules 1. Apple Swift version 5.6-dev (LLVM 3a8ddd76bc23da0, Swift 9415becb1019ebd) 2. Compiling with the current language version 3. While evaluating request IRGenRequest(IR Generation for file "/Users/davidnadoba/Repositories/Playgrounds/KeyPathCompilerCrash/Sources/ModuleB/ModuleB.swift") 4. While emitting IR SIL function "@$s7ModuleB5crashyyF". for 'crash()' (at /Users/davidnadoba/Repositories/Playgrounds/KeyPathCompilerCrash/Sources/ModuleB/ModuleB.swift:2: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 0x0000000110908aa7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 39 1 swift-frontend 0x0000000110907cc5 llvm::sys::RunSignalHandlers() + 85 2 swift-frontend 0x00000001109090e0 SignalHandler(int) + 288 3 libsystem_platform.dylib 0x00007ff806ed406d _sigtramp + 29 4 swift-frontend 0x00000001108b3600 llvm::UniqueStringSaver::save(llvm::StringRef) + 48 5 libsystem_c.dylib 0x00007ff806e10d10 abort + 123 6 libsystem_c.dylib 0x00007ff806e100be err + 0 7 swift-frontend 0x0000000110de36b3 swift::Mangle::ASTMangler::appendAnyProtocolConformance(swift::GenericSignature, swift::CanType, swift::ProtocolConformanceRef) (.cold.2) + 35 8 swift-frontend 0x000000010cc38cab swift::Mangle::ASTMangler::appendAnyProtocolConformance(swift::GenericSignature, swift::CanType, swift::ProtocolConformanceRef) + 459 9 swift-frontend 0x000000010c06a424 swift::irgen::IRGenMangler::mangleSymbolNameForMangledConformanceAccessorString(char const*, swift::CanGenericSignature, swift::CanType, swift::ProtocolConformanceRef) + 228 10 swift-frontend 0x000000010c0038fc swift::irgen::IRGenModule::emitWitnessTableRefString(swift::CanType, swift::ProtocolConformanceRef, swift::GenericSignature, bool) + 572 11 swift-frontend 0x000000010bfc87a2 void llvm::function_ref<void (swift::irgen::GenericRequirement)>::callback_fn<emitKeyPathComponent(swift::irgen::IRGenModule&, swift::irgen::ConstantStructBuilder&, swift::KeyPathPatternComponent const&, bool, swift::GenericEnvironment*, llvm::ArrayRef<swift::irgen::GenericRequirement>, swift::CanType, llvm::ArrayRef<KeyPathIndexOperand>, bool)::$_5>(long, swift::irgen::GenericRequirement) + 306 12 swift-frontend 0x000000010bff3eb6 swift::irgen::enumerateGenericSignatureRequirements(swift::CanGenericSignature, llvm::function_ref<void (swift::irgen::GenericRequirement)> const&) + 214 13 swift-frontend 0x000000010bfc2f57 emitKeyPathComponent(swift::irgen::IRGenModule&, swift::irgen::ConstantStructBuilder&, swift::KeyPathPatternComponent const&, bool, swift::GenericEnvironment*, llvm::ArrayRef<swift::irgen::GenericRequirement>, swift::CanType, llvm::ArrayRef<KeyPathIndexOperand>, bool) + 1079 14 swift-frontend 0x000000010bfc2686 swift::irgen::IRGenModule::getAddrOfKeyPathPattern(swift::KeyPathPattern*, swift::SILLocation) + 1894 15 swift-frontend 0x000000010c08dadd swift::SILInstructionVisitor<(anonymous namespace)::IRGenSILFunction, void>::visit(swift::SILInstruction*) + 21117 16 swift-frontend 0x000000010c083871 (anonymous namespace)::IRGenSILFunction::emitSILFunction() + 8113 17 swift-frontend 0x000000010c0812d2 swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 1666 18 swift-frontend 0x000000010bf5115f 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&) + 703 19 swift-frontend 0x000000010c041510 swift::IRGenRequest::evaluate(swift::Evaluator&, swift::IRGenDescriptor) const + 2384 20 swift-frontend 0x000000010c08072a 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 + 218 21 swift-frontend 0x000000010c08060e swift::SimpleRequest<swift::IRGenRequest, swift::GeneratedModule (swift::IRGenDescriptor), (swift::RequestFlags)9>::evaluateRequest(swift::IRGenRequest const&, swift::Evaluator&) + 14 22 swift-frontend 0x000000010c04cb29 llvm::Expected<swift::IRGenRequest::OutputType> swift::Evaluator::getResultUncached<swift::IRGenRequest>(swift::IRGenRequest const&) + 409 23 swift-frontend 0x000000010c043df5 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**) + 325 24 swift-frontend 0x000000010bb9954c 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*) + 1900 25 swift-frontend 0x000000010bb98675 performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 693 26 swift-frontend 0x000000010bb8d1db swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 5035 27 swift-frontend 0x000000010bb54e19 swift::mainEntry(int, char const**) + 553 28 dyld 0x00000001210b34d5 start + 421 error: Abort trap: 6 (in target 'ModuleB' from project 'KeyPathCompilerCrash')
Sample SwiftPM package attached
@swift-ci create
Attachment: Download
Environment
Tested with latest development snapshot at that time: swift-DEVELOPMENT-SNAPSHOT-2021-10-21-aAdditional Detail from JIRA
| | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug | |Assignee | None | |Priority | Medium | md5: 57c3dc0275a845d547a0e3e540197180Issue Description:
If we deifine a protocol in Module A with a property defined as an extension
Module A
trying to create a key path to `propertyInExtension` in Module B crashes the compiler
Module B
Crash Backtrace
Sample SwiftPM package attached