-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Description
Description
This issue appears to relate to Compiler crash with certain combination of parameters and typed throws #80264.
The commonality between this issue and the #80264 issue seems to be the typed throw.
Reproduction
struct MinimalExample {
// removing '-> Estimator' eliminates the crash
// removing the type from 'throws' eliminates the crash
func estimate() async throws(EstimatorError) -> Estimator {
return Estimator()
}
// removing any one of the properties of Estimator eliminates the crash
struct Estimator {
let kind: Kind
let index: Int
let stateA: Bool
let stateB: Bool
init() {
self.kind = .one
self.index = 0
self.stateA = false
self.stateB = false
}
}
enum EstimatorError: Swift.Error {}
enum Kind {
case one
}
}
Stack dump
SwiftCompile normal arm64 Compiling\ MinimalExample.swift /Users/mrips/Documents/CrashExample/CrashExample/MinimalExample.swift (in target 'CrashExample' from project 'CrashExample')
Invalid InsertValueInst operands!
%29 = insertvalue { i64, i16 } %28, i1 %25, 2, !dbg !140
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0. Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -c /Users/mrips/Documents/CrashExample/CrashExample/ContentView.swift /Users/mrips/Documents/CrashExample/CrashExample/Item.swift -primary-file /Users/mrips/Documents/CrashExample/CrashExample/MinimalExample.swift /Users/mrips/Documents/CrashExample/CrashExample/CrashExampleApp.swift /Users/mrips/Library/Developer/Xcode/DerivedData/CrashExample-anxxqvtonjijfogzjukcmohrcakp/Build/Intermediates.noindex/CrashExample.build/Debug/CrashExample.build/DerivedSources/GeneratedAssetSymbols.swift -emit-dependencies-path /Users/mrips/Library/Developer/Xcode/DerivedData/CrashExample-anxxqvtonjijfogzjukcmohrcakp/Build/Intermediates.noindex/CrashExample.build/Debug/CrashExample.build/Objects-normal/arm64/MinimalExample.d -emit-const-values-path /Users/mrips/Library/Developer/Xcode/DerivedData/CrashExample-anxxqvtonjijfogzjukcmohrcakp/Build/Intermediates.noindex/CrashExample.build/Debug/CrashExample.build/Objects-normal/arm64/MinimalExample.swiftconstvalues -emit-reference-dependencies-path /Users/mrips/Library/Developer/Xcode/DerivedData/CrashExample-anxxqvtonjijfogzjukcmohrcakp/Build/Intermediates.noindex/CrashExample.build/Debug/CrashExample.build/Objects-normal/arm64/MinimalExample.swiftdeps -serialize-diagnostics-path /Users/mrips/Library/Developer/Xcode/DerivedData/CrashExample-anxxqvtonjijfogzjukcmohrcakp/Build/Intermediates.noindex/CrashExample.build/Debug/CrashExample.build/Objects-normal/arm64/MinimalExample.dia -emit-localized-strings -emit-localized-strings-path /Users/mrips/Library/Developer/Xcode/DerivedData/CrashExample-anxxqvtonjijfogzjukcmohrcakp/Build/Intermediates.noindex/CrashExample.build/Debug/CrashExample.build/Objects-normal/arm64 -target arm64-apple-macos14.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -stack-check -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk -I /Users/mrips/Library/Developer/Xcode/DerivedData/CrashExample-anxxqvtonjijfogzjukcmohrcakp/Build/Products/Debug -F /Users/mrips/Library/Developer/Xcode/DerivedData/CrashExample-anxxqvtonjijfogzjukcmohrcakp/Build/Products/Debug -no-color-diagnostics -enable-testing -g -debug-info-format=dwarf -dwarf-version=4 -module-cache-path /Users/mrips/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -swift-version 5 -enforce-exclusivity=checked -Onone -D DEBUG -serialize-debugging-options -const-gather-protocols-file /Users/mrips/Library/Developer/Xcode/DerivedData/CrashExample-anxxqvtonjijfogzjukcmohrcakp/Build/Intermediates.noindex/CrashExample.build/Debug/CrashExample.build/Objects-normal/arm64/CrashExample_const_extract_protocols.json -enable-experimental-feature DebugDescriptionMacro -enable-bare-slash-regex -empty-abi-descriptor -validate-clang-modules-once -clang-build-session-file /Users/mrips/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation -Xcc -working-directory -Xcc /Users/mrips/Documents/CrashExample -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift -enable-anonymous-context-mangled-names -file-compilation-dir /Users/mrips/Documents/CrashExample -Xcc -ivfsstatcache -Xcc /Users/mrips/Library/Developer/Xcode/DerivedData/SDKStatCaches.noindex/macosx15.4-24E241-88b860576fb364319593bd8fb30666b0.sdkstatcache -Xcc -I/Users/mrips/Library/Developer/Xcode/DerivedData/CrashExample-anxxqvtonjijfogzjukcmohrcakp/Build/Intermediates.noindex/CrashExample.build/Debug/CrashExample.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/mrips/Library/Developer/Xcode/DerivedData/CrashExample-anxxqvtonjijfogzjukcmohrcakp/Build/Intermediates.noindex/CrashExample.build/Debug/CrashExample.build/CrashExample-generated-files.hmap -Xcc -I/Users/mrips/Library/Developer/Xcode/DerivedData/CrashExample-anxxqvtonjijfogzjukcmohrcakp/Build/Intermediates.noindex/CrashExample.build/Debug/CrashExample.build/CrashExample-own-target-headers.hmap -Xcc -I/Users/mrips/Library/Developer/Xcode/DerivedData/CrashExample-anxxqvtonjijfogzjukcmohrcakp/Build/Intermediates.noindex/CrashExample.build/Debug/CrashExample.build/CrashExample-all-target-headers.hmap -Xcc -iquote -Xcc /Users/mrips/Library/Developer/Xcode/DerivedData/CrashExample-anxxqvtonjijfogzjukcmohrcakp/Build/Intermediates.noindex/CrashExample.build/Debug/CrashExample.build/CrashExample-project-headers.hmap -Xcc -I/Users/mrips/Library/Developer/Xcode/DerivedData/CrashExample-anxxqvtonjijfogzjukcmohrcakp/Build/Products/Debug/include -Xcc -I/Users/mrips/Library/Developer/Xcode/DerivedData/CrashExample-anxxqvtonjijfogzjukcmohrcakp/Build/Intermediates.noindex/CrashExample.build/Debug/CrashExample.build/DerivedSources-normal/arm64 -Xcc -I/Users/mrips/Library/Developer/Xcode/DerivedData/CrashExample-anxxqvtonjijfogzjukcmohrcakp/Build/Intermediates.noindex/CrashExample.build/Debug/CrashExample.build/DerivedSources/arm64 -Xcc -I/Users/mrips/Library/Developer/Xcode/DerivedData/CrashExample-anxxqvtonjijfogzjukcmohrcakp/Build/Intermediates.noindex/CrashExample.build/Debug/CrashExample.build/DerivedSources -Xcc -DDEBUG=1 -module-name CrashExample -frontend-parseable-output -disable-clang-spi -target-sdk-version 15.4 -target-sdk-name macosx15.4 -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 -in-process-plugin-server-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/libSwiftInProcPluginServer.dylib -plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/local/lib/swift/host/plugins -o /Users/mrips/Library/Developer/Xcode/DerivedData/CrashExample-anxxqvtonjijfogzjukcmohrcakp/Build/Intermediates.noindex/CrashExample.build/Debug/CrashExample.build/Objects-normal/arm64/MinimalExample.o -index-unit-output-path /CrashExample.build/Debug/CrashExample.build/Objects-normal/arm64/MinimalExample.o -index-store-path /Users/mrips/Library/Developer/Xcode/DerivedData/CrashExample-anxxqvtonjijfogzjukcmohrcakp/Index.noindex/DataStore -index-system-modules
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 "/Users/mrips/Library/Developer/Xcode/DerivedData/CrashExample-anxxqvtonjijfogzjukcmohrcakp/Build/Intermediates.noindex/CrashExample.build/Debug/CrashExample.build/Objects-normal/arm64/MinimalExample.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 0x0000000106db6c28 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1 swift-frontend 0x0000000106db4a60 llvm::sys::RunSignalHandlers() + 112
2 swift-frontend 0x0000000106db7264 SignalHandler(int) + 360
3 libsystem_platform.dylib 0x0000000181f1ede4 _sigtramp + 56
4 libsystem_pthread.dylib 0x0000000181ee7f70 pthread_kill + 288
5 libsystem_c.dylib 0x0000000181df4908 abort + 128
6 swift-frontend 0x0000000100fab764 swift::DiagnosticHelper::~DiagnosticHelper() + 0
7 swift-frontend 0x0000000106d2667c llvm::report_fatal_error(llvm::Twine const&, bool) + 280
8 swift-frontend 0x0000000106d26564 llvm::report_fatal_error(llvm::Twine const&, bool) + 0
9 swift-frontend 0x0000000101226660 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 0x0000000106c40ef0 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) + 964
11 swift-frontend 0x000000010121b10c swift::performLLVMOptimizations(swift::IRGenOptions const&, llvm::Module*, llvm::TargetMachine*, llvm::raw_pwrite_stream*) + 4968
12 swift-frontend 0x000000010121c7a8 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 0x0000000100c0df88 generateCode(swift::CompilerInstance&, llvm::StringRef, llvm::Module*, llvm::GlobalVariable*) + 460
14 swift-frontend 0x0000000100c090ec 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 0x0000000100c080a8 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1036
16 swift-frontend 0x0000000100c0b654 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1764
17 swift-frontend 0x0000000100c09fd8 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3716
18 swift-frontend 0x0000000100b8e0bc swift::mainEntry(int, char const**) + 5428
19 dyld 0x0000000181b68274 start + 2840
Failed frontend command:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -c /Users/mrips/Documents/CrashExample/CrashExample/ContentView.swift /Users/mrips/Documents/CrashExample/CrashExample/Item.swift -primary-file /Users/mrips/Documents/CrashExample/CrashExample/MinimalExample.swift /Users/mrips/Documents/CrashExample/CrashExample/CrashExampleApp.swift /Users/mrips/Library/Developer/Xcode/DerivedData/CrashExample-anxxqvtonjijfogzjukcmohrcakp/Build/Intermediates.noindex/CrashExample.build/Debug/CrashExample.build/DerivedSources/GeneratedAssetSymbols.swift -emit-dependencies-path /Users/mrips/Library/Developer/Xcode/DerivedData/CrashExample-anxxqvtonjijfogzjukcmohrcakp/Build/Intermediates.noindex/CrashExample.build/Debug/CrashExample.build/Objects-normal/arm64/MinimalExample.d -emit-const-values-path /Users/mrips/Library/Developer/Xcode/DerivedData/CrashExample-anxxqvtonjijfogzjukcmohrcakp/Build/Intermediates.noindex/CrashExample.build/Debug/CrashExample.build/Objects-normal/arm64/MinimalExample.swiftconstvalues -emit-reference-dependencies-path /Users/mrips/Library/Developer/Xcode/DerivedData/CrashExample-anxxqvtonjijfogzjukcmohrcakp/Build/Intermediates.noindex/CrashExample.build/Debug/CrashExample.build/Objects-normal/arm64/MinimalExample.swiftdeps -serialize-diagnostics-path /Users/mrips/Library/Developer/Xcode/DerivedData/CrashExample-anxxqvtonjijfogzjukcmohrcakp/Build/Intermediates.noindex/CrashExample.build/Debug/CrashExample.build/Objects-normal/arm64/MinimalExample.dia -emit-localized-strings -emit-localized-strings-path /Users/mrips/Library/Developer/Xcode/DerivedData/CrashExample-anxxqvtonjijfogzjukcmohrcakp/Build/Intermediates.noindex/CrashExample.build/Debug/CrashExample.build/Objects-normal/arm64 -target arm64-apple-macos14.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -stack-check -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk -I /Users/mrips/Library/Developer/Xcode/DerivedData/CrashExample-anxxqvtonjijfogzjukcmohrcakp/Build/Products/Debug -F /Users/mrips/Library/Developer/Xcode/DerivedData/CrashExample-anxxqvtonjijfogzjukcmohrcakp/Build/Products/Debug -no-color-diagnostics -enable-testing -g -debug-info-format\=dwarf -dwarf-version\=4 -module-cache-path /Users/mrips/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -swift-version 5 -enforce-exclusivity\=checked -Onone -D DEBUG -serialize-debugging-options -const-gather-protocols-file /Users/mrips/Library/Developer/Xcode/DerivedData/CrashExample-anxxqvtonjijfogzjukcmohrcakp/Build/Intermediates.noindex/CrashExample.build/Debug/CrashExample.build/Objects-normal/arm64/CrashExample_const_extract_protocols.json -enable-experimental-feature DebugDescriptionMacro -enable-bare-slash-regex -empty-abi-descriptor -validate-clang-modules-once -clang-build-session-file /Users/mrips/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation -Xcc -working-directory -Xcc /Users/mrips/Documents/CrashExample -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift -enable-anonymous-context-mangled-names -file-compilation-dir /Users/mrips/Documents/CrashExample -Xcc -ivfsstatcache -Xcc /Users/mrips/Library/Developer/Xcode/DerivedData/SDKStatCaches.noindex/macosx15.4-24E241-88b860576fb364319593bd8fb30666b0.sdkstatcache -Xcc -I/Users/mrips/Library/Developer/Xcode/DerivedData/CrashExample-anxxqvtonjijfogzjukcmohrcakp/Build/Intermediates.noindex/CrashExample.build/Debug/CrashExample.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/mrips/Library/Developer/Xcode/DerivedData/CrashExample-anxxqvtonjijfogzjukcmohrcakp/Build/Intermediates.noindex/CrashExample.build/Debug/CrashExample.build/CrashExample-generated-files.hmap -Xcc -I/Users/mrips/Library/Developer/Xcode/DerivedData/CrashExample-anxxqvtonjijfogzjukcmohrcakp/Build/Intermediates.noindex/CrashExample.build/Debug/CrashExample.build/CrashExample-own-target-headers.hmap -Xcc -I/Users/mrips/Library/Developer/Xcode/DerivedData/CrashExample-anxxqvtonjijfogzjukcmohrcakp/Build/Intermediates.noindex/CrashExample.build/Debug/CrashExample.build/CrashExample-all-target-headers.hmap -Xcc -iquote -Xcc /Users/mrips/Library/Developer/Xcode/DerivedData/CrashExample-anxxqvtonjijfogzjukcmohrcakp/Build/Intermediates.noindex/CrashExample.build/Debug/CrashExample.build/CrashExample-project-headers.hmap -Xcc -I/Users/mrips/Library/Developer/Xcode/DerivedData/CrashExample-anxxqvtonjijfogzjukcmohrcakp/Build/Products/Debug/include -Xcc -I/Users/mrips/Library/Developer/Xcode/DerivedData/CrashExample-anxxqvtonjijfogzjukcmohrcakp/Build/Intermediates.noindex/CrashExample.build/Debug/CrashExample.build/DerivedSources-normal/arm64 -Xcc -I/Users/mrips/Library/Developer/Xcode/DerivedData/CrashExample-anxxqvtonjijfogzjukcmohrcakp/Build/Intermediates.noindex/CrashExample.build/Debug/CrashExample.build/DerivedSources/arm64 -Xcc -I/Users/mrips/Library/Developer/Xcode/DerivedData/CrashExample-anxxqvtonjijfogzjukcmohrcakp/Build/Intermediates.noindex/CrashExample.build/Debug/CrashExample.build/DerivedSources -Xcc -DDEBUG\=1 -module-name CrashExample -frontend-parseable-output -disable-clang-spi -target-sdk-version 15.4 -target-sdk-name macosx15.4 -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 -in-process-plugin-server-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/libSwiftInProcPluginServer.dylib -plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/local/lib/swift/host/plugins -o /Users/mrips/Library/Developer/Xcode/DerivedData/CrashExample-anxxqvtonjijfogzjukcmohrcakp/Build/Intermediates.noindex/CrashExample.build/Debug/CrashExample.build/Objects-normal/arm64/MinimalExample.o -index-unit-output-path /CrashExample.build/Debug/CrashExample.build/Objects-normal/arm64/MinimalExample.o -index-store-path /Users/mrips/Library/Developer/Xcode/DerivedData/CrashExample-anxxqvtonjijfogzjukcmohrcakp/Index.noindex/DataStore -index-system-modules
Command SwiftCompile failed with a nonzero exit code
Expected behavior
The 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
This issue arose immediately after updating Xcode to Version 16.3 (16E140).
The actual code that triggered the crash was buried deep in a large file in a large framework.
It took me a while to realize the the error was pointing to a specific file. The file name is referenced in part 3 of the error message, just before the stack dump.
It then took much longer to identify the code at issue in the file. Eventually, I separated the code into a dozen separate files, and, in that fashion, was able to narrow the issue down to a method with a typed throw. Eliminating the type restriction on the throw eliminated the crash.
Obviously, that solution is merely a work around pending the bug being fixed.