Skip to content

[SR-16028] Compiler Crash When Mapping via KeyPath #58289

Open
@swift-ci

Description

@swift-ci
Previous ID SR-16028
Radar None
Original Reporter VaslD (JIRA User)
Type Bug

Attachment: Download

Environment

macOS: 12.3 (21E230)

Xcode: 13.3 (13E113)

Mac: Mac mini (2018)

I think the exact issue occurs on M1 Macs as well. The compiler also crashed compiling our production code on a CI Mac. But I did not re-submit and check if the demo project would cause a crash.

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash
Assignee None
Priority Medium

md5: 28d3740145e9822f99d78e5996d1b107

Issue Description:

1.  Apple Swift version 5.6 (swiftlang-5.6.0.323.62 clang-1316.0.20.8)
2.  Compiling with the current language version
3.  While evaluating request IRGenRequest(IR Generation for file "/Users/vasld/Desktop/Swift Helpers/Swift Helpers/Demo/UnitTestClass.swift")
4.  While emitting IR SIL function "@$s4Demo5TestFC10testMethodyyFZ".
 for 'testMethod()' (at /Users/vasld/Desktop/Swift Helpers/Swift Helpers/Demo/UnitTestClass.swift:5:5)
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           0x0000000113bd6de7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 39
1  swift-frontend           0x0000000113bd5e38 llvm::sys::RunSignalHandlers() + 248
2  swift-frontend           0x0000000113bd7440 SignalHandler(int) + 288
3  libsystem_platform.dylib 0x00007ff80a377dfd _sigtramp + 29
4  libsystem_platform.dylib 000000000000000000 _sigtramp + 18446603370409525792
5  swift-frontend           0x000000010fbb8679 swift::Mangle::ASTMangler::appendAnyProtocolConformance(swift::GenericSignature, swift::CanType, swift::ProtocolConformanceRef) + 233
6  swift-frontend           0x000000010ee65828 swift::irgen::IRGenMangler::mangleSymbolNameForMangledConformanceAccessorString(char const*, swift::CanGenericSignature, swift::CanType, swift::ProtocolConformanceRef) + 200
7  swift-frontend           0x000000010edfa422 swift::irgen::IRGenModule::emitWitnessTableRefString(swift::CanType, swift::ProtocolConformanceRef, swift::GenericSignature, bool) + 546
8  swift-frontend           0x000000010edb09ea 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) + 378
9  swift-frontend           0x000000010ede90cf swift::irgen::enumerateGenericSignatureRequirements(swift::CanGenericSignature, llvm::function_ref<void (swift::irgen::GenericRequirement)> const&) + 415
10 swift-frontend           0x000000010edaa7d7 emitKeyPathComponent(swift::irgen::IRGenModule&, swift::irgen::ConstantStructBuilder&, swift::KeyPathPatternComponent const&, bool, swift::GenericEnvironment*, llvm::ArrayRef<swift::irgen::GenericRequirement>, swift::CanType, llvm::ArrayRef<KeyPathIndexOperand>, bool) + 1351
11 swift-frontend           0x000000010eda9bd6 swift::irgen::IRGenModule::getAddrOfKeyPathPattern(swift::KeyPathPattern*, swift::SILLocation) + 2310
12 swift-frontend           0x000000010ee7b57e swift::SILInstructionVisitor<(anonymous namespace)::IRGenSILFunction, void>::visit(swift::SILInstruction*) + 5086
13 swift-frontend           0x000000010ee74e32 swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 10530
14 swift-frontend           0x000000010ed1d6d3 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&) + 1875
15 swift-frontend           0x000000010ee3f889 swift::IRGenRequest::evaluate(swift::Evaluator&, swift::IRGenDescriptor) const + 9513
16 swift-frontend           0x000000010ee721ec swift::SimpleRequest<swift::IRGenRequest, swift::GeneratedModule (swift::IRGenDescriptor), (swift::RequestFlags)9>::evaluateRequest(swift::IRGenRequest const&, swift::Evaluator&) + 204
17 swift-frontend           0x000000010ee4a47c llvm::Expected<swift::IRGenRequest::OutputType> swift::Evaluator::getResultUncached<swift::IRGenRequest>(swift::IRGenRequest const&) + 828
18 swift-frontend           0x000000010ee4416c 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**) + 348
19 swift-frontend           0x000000010e90d3b3 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*) + 2499
20 swift-frontend           0x000000010e8ff261 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 15233
21 swift-frontend           0x000000010e8be5d4 swift::mainEntry(int, char const**) + 1108
22 dyld                     0x000000011d69651e start + 462

When compiling the following Swift class:

import Foundation

@objc(TestF)
class TestF: NSObject, UnitTestProtocol {
    static public func testMethod() {
        let errors = self.catchErrors()
        _ = errors.map(\.localizedDescription).joined(separator: "\n")
    }

    static public func testName() -> String! {
        return "测试 F"
    }

    static func catchErrors() -> [Error] {
        return []
    }
}

Not sure if related, the class is exported to Obj-C and implements Obj-C bridged protocol.

Build failure went away when description-mapping line was removed.

Reproduction project attached below.

Metadata

Metadata

Assignees

No one assigned

    Labels

    SILGenArea → compiler: The SIL generation stagebugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwareexistentialsFeature: values of types like `any Collection`, `Any` and `AnyObject`; type-erased valueskey pathsFeature: key paths (both native and Objective-C)multiple modulesFlag: An issue whose reproduction requires multiple modulesswift 5.6

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions