Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.0.1] Compiler crashes when attempting to compile Swift Foundation. Failed to reconstruct type. #76788

Open
sbhat98 opened this issue Sep 30, 2024 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. crash Bug: A crash, i.e., an abnormal termination of software Darwin IRGen LLVM IR generation

Comments

@sbhat98
Copy link

sbhat98 commented Sep 30, 2024

Description

When attempting to compile the latest branch of Swift Foundation (https://github.com/swiftlang/swift-foundation/) using the swift.org release of Swift 6.0.1 on MacOS, the compiler crashes.

Reproduction

  1. Clone https://github.com/swiftlang/swift-foundation/. (Tested when main pointed to b2d323e)
  2. Run swift test

Stack dump

Failed to reconstruct type for $s6Darwin14POSIXErrorCodeOD
Original type:
(enum_type decl="_errno.(file).POSIXErrorCode")
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Pass '-Xfrontend -disable-round-trip-debug-types' to disable this assertion.
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.  Program arguments: /Library/Developer/Toolchains/swift-6.0.1-RELEASE.xctoolchain/usr/bin/swift-frontend -frontend -c -filelist /var/folders/cj/0w4bb6k17375x2djs9w7k0x80000gn/T/TemporaryDirectory.oxtmqV/sources-1 -primary-file /Users/shishir/code/swift-foundation/Sources/FoundationEssentials/Data/Pointers+DataProtocol.swift -primary-file /Users/shishir/code/swift-foundation/Sources/FoundationEssentials/Date.swift -primary-file /Users/shishir/code/swift-foundation/Sources/FoundationEssentials/DateInterval.swift -primary-file /Users/shishir/code/swift-foundation/Sources/FoundationEssentials/Decimal/Decimal+Compatibility.swift -primary-file /Users/shishir/code/swift-foundation/Sources/FoundationEssentials/Decimal/Decimal+Conformances.swift -primary-file /Users/shishir/code/swift-foundation/Sources/FoundationEssentials/Decimal/Decimal+Math.swift -primary-file /Users/shishir/code/swift-foundation/Sources/FoundationEssentials/Decimal/Decimal.swift -primary-file /Users/shishir/code/swift-foundation/Sources/FoundationEssentials/Error/CocoaError+FilePath.swift -primary-file /Users/shishir/code/swift-foundation/Sources/FoundationEssentials/Error/CocoaError.swift -primary-file /Users/shishir/code/swift-foundation/Sources/FoundationEssentials/Error/ErrorCodes+POSIX.swift -primary-file /Users/shishir/code/swift-foundation/Sources/FoundationEssentials/Error/ErrorCodes+Win32.swift -primary-file /Users/shishir/code/swift-foundation/Sources/FoundationEssentials/Error/ErrorCodes.swift -primary-file /Users/shishir/code/swift-foundation/Sources/FoundationEssentials/FileManager/FileManager+Basics.swift -primary-file /Users/shishir/code/swift-foundation/Sources/FoundationEssentials/FileManager/FileManager+Bridge.swift -primary-file /Users/shishir/code/swift-foundation/Sources/FoundationEssentials/FileManager/FileManager+Directories.swift -primary-file /Users/shishir/code/swift-foundation/Sources/FoundationEssentials/FileManager/FileManager+Files.swift -supplementary-output-file-map /var/folders/cj/0w4bb6k17375x2djs9w7k0x80000gn/T/TemporaryDirectory.oxtmqV/supplementaryOutputs-4 -target x86_64-apple-macosx13.3 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk -I /Users/shishir/code/swift-foundation/.build/x86_64-apple-macosx/debug/Modules -I /Library/Developer/Toolchains/swift-6.0.1-RELEASE.xctoolchain/usr/lib/swift/macosx/testing -I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -color-diagnostics -enable-testing -g -debug-info-format=dwarf -dwarf-version=4 -module-cache-path /Users/shishir/code/swift-foundation/.build/x86_64-apple-macosx/debug/ModuleCache -swift-version 5 -Onone -D SWIFT_PACKAGE -D DEBUG -load-plugin-executable /Users/shishir/code/swift-foundation/.build/x86_64-apple-macosx/debug/FoundationMacros-tool#FoundationMacros -enable-experimental-feature VariadicGenerics -enable-experimental-feature AccessLevelOnImport -enable-experimental-feature "AvailabilityMacro=FoundationPreview 0.1:macOS 13.3, iOS 16.4, tvOS 16.4, watchOS 9.4" -enable-experimental-feature "AvailabilityMacro=FoundationPredicate 0.1:macOS 14, iOS 17, tvOS 17, watchOS 10" -enable-experimental-feature "AvailabilityMacro=FoundationPredicateRegex 0.1:macOS 15, iOS 18, tvOS 18, watchOS 11" -enable-experimental-feature "AvailabilityMacro=FoundationPreview 0.2:macOS 13.3, iOS 16.4, tvOS 16.4, watchOS 9.4" -enable-experimental-feature "AvailabilityMacro=FoundationPredicate 0.2:macOS 14, iOS 17, tvOS 17, watchOS 10" -enable-experimental-feature "AvailabilityMacro=FoundationPredicateRegex 0.2:macOS 15, iOS 18, tvOS 18, watchOS 11" -enable-experimental-feature "AvailabilityMacro=FoundationPreview 0.3:macOS 13.3, iOS 16.4, tvOS 16.4, watchOS 9.4" -enable-experimental-feature "AvailabilityMacro=FoundationPredicate 0.3:macOS 14, iOS 17, tvOS 17, watchOS 10" -enable-experimental-feature "AvailabilityMacro=FoundationPredicateRegex 0.3:macOS 15, iOS 18, tvOS 18, watchOS 11" -enable-experimental-feature "AvailabilityMacro=FoundationPreview 0.4:macOS 13.3, iOS 16.4, tvOS 16.4, watchOS 9.4" -enable-experimental-feature "AvailabilityMacro=FoundationPredicate 0.4:macOS 14, iOS 17, tvOS 17, watchOS 10" -enable-experimental-feature "AvailabilityMacro=FoundationPredicateRegex 0.4:macOS 15, iOS 18, tvOS 18, watchOS 11" -enable-experimental-feature "AvailabilityMacro=FoundationPreview 6.0.2:macOS 13.3, iOS 16.4, tvOS 16.4, watchOS 9.4" -enable-experimental-feature "AvailabilityMacro=FoundationPredicate 6.0.2:macOS 14, iOS 17, tvOS 17, watchOS 10" -enable-experimental-feature "AvailabilityMacro=FoundationPredicateRegex 6.0.2:macOS 15, iOS 18, tvOS 18, watchOS 11" -enable-experimental-feature StrictConcurrency -enable-upcoming-feature InferSendableFromCaptures -empty-abi-descriptor -plugin-path /Library/Developer/Toolchains/swift-6.0.1-RELEASE.xctoolchain/usr/lib/swift/host/plugins/testing -resource-dir /Library/Developer/Toolchains/swift-6.0.1-RELEASE.xctoolchain/usr/lib/swift -enable-anonymous-context-mangled-names -file-compilation-dir /Users/shishir/code/swift-foundation -Xcc -fmodule-map-file=/Users/shishir/code/swift-foundation/.build/checkouts/swift-syntax/Sources/_SwiftSyntaxCShims/include/module.modulemap -Xcc -I -Xcc /Users/shishir/code/swift-foundation/.build/checkouts/swift-syntax/Sources/_SwiftSyntaxCShims/include -Xcc -fmodule-map-file=/Users/shishir/code/swift-foundation/Sources/_FoundationCShims/include/module.modulemap -Xcc -I -Xcc /Users/shishir/code/swift-foundation/Sources/_FoundationCShims/include -Xcc -isysroot -Xcc /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk -Xcc -F -Xcc /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -Xcc -fPIC -Xcc -g -module-name FoundationEssentials -package-name swift_foundation -plugin-path /Library/Developer/Toolchains/swift-6.0.1-RELEASE.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Library/Developer/Toolchains/swift-6.0.1-RELEASE.xctoolchain/usr/local/lib/swift/host/plugins -target-sdk-version 15.0 -target-sdk-name macosx15.0 -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 -parse-as-library -o /Users/shishir/code/swift-foundation/.build/x86_64-apple-macosx/debug/FoundationEssentials.build/Pointers+DataProtocol.swift.o -o /Users/shishir/code/swift-foundation/.build/x86_64-apple-macosx/debug/FoundationEssentials.build/Date.swift.o -o /Users/shishir/code/swift-foundation/.build/x86_64-apple-macosx/debug/FoundationEssentials.build/DateInterval.swift.o -o /Users/shishir/code/swift-foundation/.build/x86_64-apple-macosx/debug/FoundationEssentials.build/Decimal+Compatibility.swift.o -o /Users/shishir/code/swift-foundation/.build/x86_64-apple-macosx/debug/FoundationEssentials.build/Decimal+Conformances.swift.o -o /Users/shishir/code/swift-foundation/.build/x86_64-apple-macosx/debug/FoundationEssentials.build/Decimal+Math.swift.o -o /Users/shishir/code/swift-foundation/.build/x86_64-apple-macosx/debug/FoundationEssentials.build/Decimal.swift.o -o /Users/shishir/code/swift-foundation/.build/x86_64-apple-macosx/debug/FoundationEssentials.build/CocoaError+FilePath.swift.o -o /Users/shishir/code/swift-foundation/.build/x86_64-apple-macosx/debug/FoundationEssentials.build/CocoaError.swift.o -o /Users/shishir/code/swift-foundation/.build/x86_64-apple-macosx/debug/FoundationEssentials.build/ErrorCodes+POSIX.swift.o -o /Users/shishir/code/swift-foundation/.build/x86_64-apple-macosx/debug/FoundationEssentials.build/ErrorCodes+Win32.swift.o -o /Users/shishir/code/swift-foundation/.build/x86_64-apple-macosx/debug/FoundationEssentials.build/ErrorCodes.swift.o -o /Users/shishir/code/swift-foundation/.build/x86_64-apple-macosx/debug/FoundationEssentials.build/FileManager+Basics.swift.o -o /Users/shishir/code/swift-foundation/.build/x86_64-apple-macosx/debug/FoundationEssentials.build/FileManager+Bridge.swift.o -o /Users/shishir/code/swift-foundation/.build/x86_64-apple-macosx/debug/FoundationEssentials.build/FileManager+Directories.swift.o -o /Users/shishir/code/swift-foundation/.build/x86_64-apple-macosx/debug/FoundationEssentials.build/FileManager+Files.swift.o -index-store-path /Users/shishir/code/swift-foundation/.build/x86_64-apple-macosx/debug/index/store -index-system-modules
1.  Apple Swift version 6.0.1 (swift-6.0.1-RELEASE)
2.  Compiling with effective version 5.10
3.  Contents of /var/folders/cj/0w4bb6k17375x2djs9w7k0x80000gn/T/TemporaryDirectory.oxtmqV/sources-1:
4.  While evaluating request IRGenRequest(IR Generation for file "/Users/shishir/code/swift-foundation/Sources/FoundationEssentials/Error/CocoaError+FilePath.swift")
5.  While emitting IR SIL function "@$s20FoundationEssentials10POSIXErrorV5errnoACSgs5Int32V_tc33_FBA71097CBDF77AA6E663B7714FA1434LlfC".
 for 'init(errno:)' (at /Users/shishir/code/swift-foundation/Sources/FoundationEssentials/Error/CocoaError+FilePath.swift:73:17)
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           0x000000010e60c458 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 40
1  swift-frontend           0x000000010e60a945 llvm::sys::RunSignalHandlers() + 85
2  swift-frontend           0x000000010e60caae SignalHandler(int) + 270
3  libsystem_platform.dylib 0x00007ff802876e9d _sigtramp + 29
4  libsystem_platform.dylib 0x00007f8846accd68 _sigtramp + 18446743593816514280
5  libsystem_c.dylib        0x00007ff802762b19 abort + 126
6  swift-frontend           0x000000010e6ffbfd (anonymous namespace)::IRGenDebugInfoImpl::getOrCreateType(swift::irgen::DebugTypeInfo) (.cold.23) + 141
7  swift-frontend           0x000000010896633b (anonymous namespace)::IRGenDebugInfoImpl::getOrCreateType(swift::irgen::DebugTypeInfo) + 4699
8  swift-frontend           0x000000010895f37a (anonymous namespace)::IRGenDebugInfoImpl::emitVariableDeclaration(swift::irgen::IRBuilder&, llvm::ArrayRef<llvm::Value*>, swift::irgen::DebugTypeInfo, swift::SILDebugScope const*, std::__1::optional<swift::SILLocation>, swift::SILDebugVariable, swift::irgen::IndirectionKind, swift::irgen::ArtificialKind, swift::irgen::AddrDbgInstrKind) + 602
9  swift-frontend           0x000000010895f0dc swift::irgen::IRGenDebugInfo::emitVariableDeclaration(swift::irgen::IRBuilder&, llvm::ArrayRef<llvm::Value*>, swift::irgen::DebugTypeInfo, swift::SILDebugScope const*, std::__1::optional<swift::SILLocation>, swift::SILDebugVariable, swift::irgen::IndirectionKind, swift::irgen::ArtificialKind, swift::irgen::AddrDbgInstrKind) + 300
10 swift-frontend           0x00000001089c9e9a (anonymous namespace)::IRGenSILFunction::visitSILBasicBlock(swift::SILBasicBlock*) + 94074
11 swift-frontend           0x00000001089b1eac (anonymous namespace)::IRGenSILFunction::emitSILFunction() + 11884
12 swift-frontend           0x00000001089ae9f3 swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 2339
13 swift-frontend           0x00000001088197b4 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&) + 820
14 swift-frontend           0x000000010894ebe3 swift::IRGenRequest::evaluate(swift::Evaluator&, swift::IRGenDescriptor) const + 2755
15 swift-frontend           0x00000001089adbbf 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 + 223
16 swift-frontend           0x00000001089ada9e swift::SimpleRequest<swift::IRGenRequest, swift::GeneratedModule (swift::IRGenDescriptor), (swift::RequestFlags)9>::evaluateRequest(swift::IRGenRequest const&, swift::Evaluator&) + 14
17 swift-frontend           0x0000000108958221 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'()) + 209
18 swift-frontend           0x0000000108951460 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**) + 304
19 swift-frontend           0x00000001083a3234 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>>>) + 180
20 swift-frontend           0x000000010839ecf7 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*) + 1575
21 swift-frontend           0x000000010839de6e swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 830
22 swift-frontend           0x00000001083acc1f withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) + 143
23 swift-frontend           0x00000001083a0547 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 967
24 swift-frontend           0x000000010839f98f swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2927
25 swift-frontend           0x000000010818572c swift::mainEntry(int, char const**) + 2636
26 dyld                     0x00007ff8024b42cd start + 1805

error: fatalError

Expected behavior

The code builds without error

Environment

$ swift --version

Apple Swift version 6.0.1 (swift-6.0.1-RELEASE)
Target: x86_64-apple-macosx15.0

Additional information

It's unclear if this is a regression from 6.0.0 since there was another issue causing this to be unable to be built in the previous version (#76534)

@sbhat98 sbhat98 added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. crash Bug: A crash, i.e., an abnormal termination of software triage needed This issue needs more specific labels labels Sep 30, 2024
@jmschonfeld jmschonfeld added IRGen LLVM IR generation Darwin and removed triage needed This issue needs more specific labels labels Oct 8, 2024
@ulian-onua
Copy link

I can confirm that I also have a similar Swift Compiler crash when trying to build Swift Package for the iOS app.

image

@IamYJLee
Copy link

Workaround

You can disable this assertion by adding the option to Other Swift Flags as shown below.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. crash Bug: A crash, i.e., an abnormal termination of software Darwin IRGen LLVM IR generation
Projects
None yet
Development

No branches or pull requests

4 participants