Skip to content

Compiler crash with certain combination of parameters and typed throws #80264

@jpulik

Description

@jpulik

Description

Swift compiler crashes with specific combination of parameters (see reproduction code).
If the param3 is commented out it will compile successfully.
Or if the param3 type is changed to Int it will compile successfully too.
Interesting note is if the typed throws is removed (ProviderError) it won't crash too.
It is only problematic in this specific scenario, I'm not really sure what is the issue here.

Reproduction

struct CarModel {
    let param1: Int
    let param2: Bool
    let param3: Bool
}

enum ProviderError: Error {
    case general
}

protocol CarProvider {
    func fetchCar() async throws(ProviderError) -> CarModel
}

struct CarProviderImpl: CarProvider {
    func fetchCar() async throws(ProviderError) -> CarModel {
        CarModel(param1: 0, param2: false, param3: false)
    }
}

Stack dump

error: compile command failed due to signal 6 (use -v to see invocation)
Invalid InsertValueInst operands!
  %29 = insertvalue { i64, i16 } %28, i1 %25, 2
Invalid InsertValueInst operands!
  %49 = insertvalue { i64, i16 } %48, i1 %45, 2
<unknown>:0: error: fatal error encountered during compilation; please submit a bug report (https://swift.org/contributing/#reporting-bugs)
<unknown>:0: note: Broken module found, compilation aborted!
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.	Program arguments: /Users/jpulik/Downloads/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -c -primary-file TestProvider.swift -target arm64-apple-macosx15.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -stack-check -sdk /Users/jpulik/Downloads/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk -color-diagnostics -new-driver-path /Users/jpulik/Downloads/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-driver -empty-abi-descriptor -resource-dir /Users/jpulik/Downloads/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift -module-name TestProvider -disable-clang-spi -target-sdk-version 15.4 -target-sdk-name macosx15.4 -external-plugin-path /Users/jpulik/Downloads/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/swift/host/plugins#/Users/jpulik/Downloads/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -external-plugin-path /Users/jpulik/Downloads/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/local/lib/swift/host/plugins#/Users/jpulik/Downloads/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -in-process-plugin-server-path /Users/jpulik/Downloads/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/libSwiftInProcPluginServer.dylib -plugin-path /Users/jpulik/Downloads/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Users/jpulik/Downloads/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/local/lib/swift/host/plugins -o /var/folders/wp/gshq6lfs1614cbxhsnfjqg1r0000gn/T/TemporaryDirectory.pLiTaF/TestProvider-1.o
1.	Apple Swift version 6.1 (swiftlang-6.1.0.110.21 clang-1700.0.13.3)
2.	Compiling with effective version 5.10
3.	Running pass "verify" on module "/var/folders/wp/gshq6lfs1614cbxhsnfjqg1r0000gn/T/TemporaryDirectory.pLiTaF/TestProvider-1.o"
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           0x0000000106e12c28 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x0000000106e10a60 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x0000000106e13264 SignalHandler(int) + 360
3  libsystem_platform.dylib 0x0000000186e72de4 _sigtramp + 56
4  libsystem_pthread.dylib  0x0000000186e3bf70 pthread_kill + 288
5  libsystem_c.dylib        0x0000000186d48908 abort + 128
6  swift-frontend           0x0000000101007764 swift::DiagnosticHelper::~DiagnosticHelper() + 0
7  swift-frontend           0x0000000106d8267c llvm::report_fatal_error(llvm::Twine const&, bool) + 280
8  swift-frontend           0x0000000106d82564 llvm::report_fatal_error(llvm::Twine const&, bool) + 0
9  swift-frontend           0x0000000101282660 llvm::detail::PassModel<llvm::Module, llvm::VerifierPass, llvm::AnalysisManager<llvm::Module>>::printPipeline(llvm::raw_ostream&, llvm::function_ref<llvm::StringRef (llvm::StringRef)>) + 0
10 swift-frontend           0x0000000106c9cef0 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) + 964
11 swift-frontend           0x000000010127710c swift::performLLVMOptimizations(swift::IRGenOptions const&, llvm::Module*, llvm::TargetMachine*, llvm::raw_pwrite_stream*) + 4968
12 swift-frontend           0x00000001012787a8 swift::performLLVM(swift::IRGenOptions const&, swift::DiagnosticEngine&, llvm::sys::SmartMutex<false>*, llvm::GlobalVariable*, llvm::Module*, llvm::TargetMachine*, llvm::StringRef, llvm::vfs::OutputBackend&, swift::UnifiedStatsReporter*) + 2552
13 swift-frontend           0x0000000100c69f88 generateCode(swift::CompilerInstance&, llvm::StringRef, llvm::Module*, llvm::GlobalVariable*) + 460
14 swift-frontend           0x0000000100c650ec 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*) + 2220
15 swift-frontend           0x0000000100c640a8 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1036
16 swift-frontend           0x0000000100c67654 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1764
17 swift-frontend           0x0000000100c65fd8 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3716
18 swift-frontend           0x0000000100bea0bc swift::mainEntry(int, char const**) + 5428
19 dyld                     0x0000000186abc274 start + 2840

Expected behavior

Compiler should not crash.

Environment

swift-driver version: 1.120.5 Apple Swift version 6.1 (swiftlang-6.1.0.110.21 clang-1700.0.13.3)
Target: arm64-apple-macosx15.0

Additional information

No response

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.crashBug: A crash, i.e., an abnormal termination of software

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions