swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.6k stars 10.37k forks source link

[Embedded] Compiler crash when building Concurrency without bootstrapping #69124

Closed Jumhyn closed 1 year ago

Jumhyn commented 1 year ago

When building the compiler without bootstrapping enabled I get a crash related to Embedded Swift. Haven't enabled any special settings related to embedded mode, not sure what's triggering the concurrency lib to build in embedded mode...

Assertion failed: (!f->isGeneric()), function addLazyFunction, file GenDecl.cpp, line 1573.
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.  Program arguments: /Users/freddy/Developer/git/swift-project/build/Ninja-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-arm64/bin/swift-frontend -frontend -c /Users/freddy/Developer/git/swift-project/swift/stdlib/public/Concurrency/Task.swift /Users/freddy/Developer/git/swift-project/swift/stdlib/public/Concurrency/AsyncLet.swift /Users/freddy/Developer/git/swift-project/swift/stdlib/public/Concurrency/Executor.swift /Users/freddy/Developer/git/swift-project/swift/stdlib/public/Concurrency/Errors.swift /Users/freddy/Developer/git/swift-project/swift/stdlib/public/Concurrency/PartialAsyncTask.swift -supplementary-output-file-map /var/folders/0p/2zrdbwjd4hj1ckt7jy6yfz_40000gn/T/TemporaryDirectory.ZVPyfz/supplementaryOutputs-1 -disable-objc-attr-requires-foundation-module -target x86_64-apple-macos10.13 -disable-objc-interop -I /Users/freddy/Developer/git/swift-project/build/Ninja-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-arm64/lib/swift/embedded -color-diagnostics -g -module-cache-path /Users/freddy/Developer/git/swift-project/build/Ninja-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-arm64/module-cache -module-link-name swift_Concurrency -parse-stdlib -static -swift-version 5 -O -D INTERNAL_CHECKS_ENABLED -D SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY -D SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED -D SWIFT_ENABLE_RUNTIME_FUNCTION_COUNTERS -D SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING -D SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING -D SWIFT_ENABLE_EXPERIMENTAL_OBSERVATION -D SWIFT_RUNTIME_OS_VERSIONING -D SWIFT_STDLIB_ENABLE_UNICODE_DATA -D SWIFT_STDLIB_ENABLE_VECTOR_TYPES -D SWIFT_STDLIB_HAS_COMMANDLINE -D SWIFT_STDLIB_HAS_STDIN -D SWIFT_STDLIB_HAS_ENVIRON -D SWIFT_STDLIB_SINGLE_THREADED_CONCURRENCY -D SWIFT_THREADING_ -D SWIFT_CONCURRENCY_EMBEDDED -new-driver-path /Users/freddy/Developer/git/swift-project/build/Ninja-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-arm64/bin/swift-driver -enforce-exclusivity=unchecked -disable-autolinking-runtime-compatibility-concurrency -disable-objc-interop -swift-async-frame-pointer=always -define-availability "SwiftStdlib 9999:macOS 9999, iOS 9999, watchOS 9999, tvOS 9999" -define-availability "SwiftStdlib 5.0:macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2" -define-availability "SwiftStdlib 5.1:macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0" -define-availability "SwiftStdlib 5.2:macOS 10.15.4, iOS 13.4, watchOS 6.2, tvOS 13.4" -define-availability "SwiftStdlib 5.3:macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0" -define-availability "SwiftStdlib 5.4:macOS 11.3, iOS 14.5, watchOS 7.4, tvOS 14.5" -define-availability "SwiftStdlib 5.5:macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0" -define-availability "SwiftStdlib 5.6:macOS 12.3, iOS 15.4, watchOS 8.5, tvOS 15.4" -define-availability "SwiftStdlib 5.7:macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0" -define-availability "SwiftStdlib 5.8:macOS 13.3, iOS 16.4, watchOS 9.4, tvOS 16.4" -define-availability "SwiftStdlib 5.9:macOS 14.0, iOS 17.0, watchOS 10.0, tvOS 17.0" -define-availability "SwiftStdlib 5.10:macOS 9999, iOS 9999, watchOS 9999, tvOS 9999" -target-min-inlining-version min -enable-experimental-feature Embedded -empty-abi-descriptor -resource-dir /Users/freddy/Developer/git/swift-project/build/Ninja-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-arm64/lib/swift -Xcc -DSWIFT_STDLIB_HAS_ENVIRON -Xcc -D__MACH__ -Xcc -D__APPLE__ -Xcc -ffreestanding -module-name _Concurrency -plugin-path /Users/freddy/Developer/git/swift-project/build/Ninja-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-arm64/lib/swift/host/plugins -plugin-path /Users/freddy/Developer/git/swift-project/build/Ninja-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-arm64/local/lib/swift/host/plugins -enable-default-cmo -parse-as-library -o /Users/freddy/Developer/git/swift-project/build/Ninja-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-arm64/stdlib/public/Concurrency/embedded/x86_64-apple-macos/_Concurrency.o -runtime-compatibility-version none -disable-autolinking-runtime-compatibility-dynamic-replacements
1.  Swift version 5.11-dev (LLVM 1cf95e7e61a3714, Swift 1aa190a85327d5f)
2.  Compiling with the current language version
3.  While evaluating request IRGenRequest(IR Generation for module _Concurrency)
4.  While emitting IR SIL function "@$sScTss5NeverORszABRs_rlE15currentPriorityScPvgZ".
 for getter for currentPriority (at /Users/freddy/Developer/git/swift-project/swift/stdlib/public/Concurrency/Task.swift:419:21)
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           0x00000001097ae318 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x00000001097ad5e0 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x00000001097ae954 SignalHandler(int) + 304
3  libsystem_platform.dylib 0x000000018e696a24 _sigtramp + 56
4  libsystem_pthread.dylib  0x000000018e667cc0 pthread_kill + 288
5  libsystem_c.dylib        0x000000018e577a40 abort + 180
6  libsystem_c.dylib        0x000000018e576d30 err + 0
7  swift-frontend           0x0000000102a21204 swift::irgen::IRGenerator::addLazyFunction(swift::SILFunction*) + 152
8  swift-frontend           0x0000000102a248b8 swift::irgen::IRGenModule::getAddrOfSILFunction(swift::SILFunction*, swift::ForDefinition_t, bool, bool) + 1552
9  swift-frontend           0x0000000102d79948 (anonymous namespace)::IRGenSILFunction::visitFunctionRefBaseInst(swift::FunctionRefBaseInst*) + 212
10 swift-frontend           0x0000000102d5c6a4 (anonymous namespace)::IRGenSILFunction::visitFunctionRefInst(swift::FunctionRefInst*) + 32
11 swift-frontend           0x0000000102d58014 swift::SILInstructionVisitor<(anonymous namespace)::IRGenSILFunction, void>::visit(swift::SILInstruction*) + 332
12 swift-frontend           0x0000000102d40440 (anonymous namespace)::IRGenSILFunction::visitSILBasicBlock(swift::SILBasicBlock*) + 1236
13 swift-frontend           0x0000000102d350c4 (anonymous namespace)::IRGenSILFunction::emitSILFunction() + 2180
14 swift-frontend           0x0000000102d34750 swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 252
15 swift-frontend           0x0000000102a1e2a0 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&) + 1048
16 swift-frontend           0x0000000102c3d288 swift::IRGenRequest::evaluate(swift::Evaluator&, swift::IRGenDescriptor) const + 1000
17 swift-frontend           0x0000000102d334b8 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 + 120
18 swift-frontend           0x0000000102d333c4 swift::SimpleRequest<swift::IRGenRequest, swift::GeneratedModule (swift::IRGenDescriptor), (swift::RequestFlags)9>::evaluateRequest(swift::IRGenRequest const&, swift::Evaluator&) + 40
19 swift-frontend           0x0000000102c811f8 llvm::Expected<swift::IRGenRequest::OutputType> swift::Evaluator::getResultUncached<swift::IRGenRequest>(swift::IRGenRequest const&) + 288
20 swift-frontend           0x0000000102c3f418 llvm::Expected<swift::IRGenRequest::OutputType> swift::Evaluator::operator()<swift::IRGenRequest, (void*)0>(swift::IRGenRequest const&) + 40
21 swift-frontend           0x0000000102c3e89c swift::performIRGeneration(swift::ModuleDecl*, swift::IRGenOptions const&, swift::TBDGenOptions const&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::ArrayRef<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>, llvm::GlobalVariable**) + 492
22 swift-frontend           0x00000001022acd7c 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>>>) + 436
23 swift-frontend           0x00000001022a7164 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*) + 1960
24 swift-frontend           0x00000001022a63fc swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 304
25 swift-frontend           0x00000001022d4808 performAction(swift::CompilerInstance&, int&, swift::FrontendObserver*)::$_30::operator()(swift::CompilerInstance&) const + 140
26 swift-frontend           0x00000001022d476c bool llvm::function_ref<bool (swift::CompilerInstance&)>::callback_fn<performAction(swift::CompilerInstance&, int&, swift::FrontendObserver*)::$_30>(long, swift::CompilerInstance&) + 32
27 swift-frontend           0x00000001022d3b1c llvm::function_ref<bool (swift::CompilerInstance&)>::operator()(swift::CompilerInstance&) const + 40
28 swift-frontend           0x00000001022d2aa0 withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) + 452
29 swift-frontend           0x00000001022cd9d0 performAction(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1268
30 swift-frontend           0x00000001022a9170 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 256
31 swift-frontend           0x00000001022a7e0c swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2368
32 swift-frontend           0x00000001021711bc run_driver(llvm::StringRef, llvm::ArrayRef<char const*>, llvm::ArrayRef<char const*>) + 320
33 swift-frontend           0x0000000102170620 swift::mainEntry(int, char const**) + 1148
34 swift-frontend           0x000000010216fdb8 main + 36
35 dyld                     0x000000018e2ed058 start + 2224

cc @kubamracek

kubamracek commented 1 year ago

@Jumhyn could you check if this is resolved by https://github.com/apple/swift/pull/69044?

AnthonyLatsis commented 1 year ago

With a debug compiler, this only seems to reproduce with --bootstrapping=off.

Jumhyn commented 1 year ago

@kubamracek I was able to repro this at top-of-tree yesterday so I don't think it's solved by that PR sadly.

@AnthonyLatsis hmmm, I don't think I was building with bootstrapping off, but I have in the past so maybe I haven't reconfigured. I'll see if i can repro today

Jumhyn commented 1 year ago

Confirmed @AnthonyLatsis that this only appears to reproduce with --bootstrapping=off, and I can reproduce it in release mode in that case as well. A clean build with default boostrapping settings does not have the issue but recompiling with --bootstrapping=off --reconfigure reproduces.

@kubamracek I just reproduced with the following build command:

utils/build-script --skip-build-benchmarks \
  --skip-ios --skip-watchos --skip-tvos --swift-darwin-supported-archs "$(uname -m)" \
  --sccache --release-debuginfo --swift-disable-dead-stripping --test --bootstrapping=off --reconfigure

at the following commit:

commit fd6a4947e61dfc5cef09eed09c265e9cb459a483 (origin/main, origin/HEAD)
Merge: 9ba500d4e49 801b9700124
Author: Alastair Houghton <ahoughton@apple.com>
Date:   Thu Oct 12 11:50:15 2023 +0100
Jumhyn commented 1 year ago

I've updated the title and description to reflect that this appears to be related to bootstrapping, not debug mode

kubamracek commented 1 year ago

Fixing in https://github.com/apple/swift/pull/69165.

Jumhyn commented 1 year ago

Thank you @kubamracek!