-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Open
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.concurrencyFeature: umbrella label for concurrency language featuresFeature: umbrella label for concurrency language featurescrashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of software
Description
Description
A Mutex
with a generic Value
inside a generic class crashes the compiler.
Swift 6.0.2, same behavior on macOS and linux docker containers (both arm and amd64).
The weirdest part is if I comment stuff out a bit to get the file compiling, I can then comment the mutex back in and it compiles without errors. After a swift package clean
the crasher returns.
Happened in the wild here:
sliemeobn/elementary@fd86c1d
Reproduction
import Synchronization
final class SendOnceBox<Value>: Sendable {
let mutex: Mutex<Value?>
init(_ value: sending Value) {
mutex = Mutex(value)
}
func tryTake() -> sending Value? {
mutex.withLock { value -> sending Value? in
let result = value
value = nil
return result
}
}
}
Stack dump
error: compile command failed due to signal 6 (use -v to see invocation)
Metadata for archetype not bound in function.
The metadata could be missing entirely because it needs to be passed to the function.
Or the metadata is present and not bound in which case setScopedLocalTypeMetadata or similar must be called.
Archetype without metadata: Value
(primary_archetype_type address=0x12a150a78 conforms_to="Swift.(file).Copyable" conforms_to="Swift.(file).Escapable" name="Value"
(interface_type=generic_type_param_type depth=0 index=0 decl="Elementary.(file).SendOnceBox.Value@/Users/simon/dev/swift-projects/elementary/Sources/Elementary/ServerSupport/SendOnceBox.swift:6:25"))
Function:
; Function Attrs: noinline nounwind
define linkonce_odr hidden ptr @"$s15Synchronization5MutexVyxSgGlWOb"(ptr %0, ptr %1, ptr %2, ptr %3) #7 !dbg !6 {
%5 = alloca i1, align 1
%6 = getelementptr inbounds %T15Synchronization5MutexV, ptr %1, i32 0, i32 0, !dbg !10
%7 = getelementptr inbounds %T15Synchronization5MutexV, ptr %0, i32 0, i32 0, !dbg !10
call void @llvm.memcpy.p0.p0.i64(ptr align 4 %6, ptr align 4 %7, i64 4, i1 false), !dbg !10
%8 = getelementptr inbounds i32, ptr %3, i64 7, !dbg !10
%9 = load i32, ptr %8, align 8, !dbg !10
%10 = getelementptr inbounds i8, ptr %1, i32 %9, !dbg !10
%11 = getelementptr inbounds i32, ptr %3, i64 7, !dbg !10
%12 = load i32, ptr %11, align 8, !dbg !10
%13 = getelementptr inbounds i8, ptr %0, i32 %12, !dbg !10
}
LocalTypeData:
(0x12a16a6c8 (Mutex<Optional<Value>>), FormalTypeMetadata) => [
(universal) concrete: 0x114505978
ptr %3
]
(0x12a26e260 (_Cell<Optional<Value>>), FormalTypeMetadata) => [
(universal) concrete: 0x114505950
ptr %2
]
Assertion failed: (archetype->getParent() && "Not a nested archetype"), function emitArchetypeTypeMetadataRef, file GenArchetype.cpp, line 99.
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.2-RELEASE.xctoolchain/usr/bin/swift-frontend -frontend -c /Users/simon/dev/swift-projects/elementary/Sources/Elementary/Core/AsyncContent.swift /Users/simon/dev/swift-projects/elementary/Sources/Elementary/Core/AsyncForEach.swift /Users/simon/dev/swift-projects/elementary/Sources/Elementary/Core/AttributeStorage.swift /Users/simon/dev/swift-projects/elementary/Sources/Elementary/Core/CoreModel.swift /Users/simon/dev/swift-projects/elementary/Sources/Elementary/Core/Environment.swift /Users/simon/dev/swift-projects/elementary/Sources/Elementary/Core/ForEach.swift /Users/simon/dev/swift-projects/elementary/Sources/Elementary/Core/Html+Attributes.swift /Users/simon/dev/swift-projects/elementary/Sources/Elementary/Core/Html+Elements.swift /Users/simon/dev/swift-projects/elementary/Sources/Elementary/Core/HtmlBuilder+Tuples.swift /Users/simon/dev/swift-projects/elementary/Sources/Elementary/Core/HtmlBuilder.swift /Users/simon/dev/swift-projects/elementary/Sources/Elementary/Core/HtmlElement+Async.swift /Users/simon/dev/swift-projects/elementary/Sources/Elementary/Html+Rendering.swift /Users/simon/dev/swift-projects/elementary/Sources/Elementary/HtmlAttributes+Events.swift /Users/simon/dev/swift-projects/elementary/Sources/Elementary/HtmlAttributes.swift /Users/simon/dev/swift-projects/elementary/Sources/Elementary/HtmlDocument.swift /Users/simon/dev/swift-projects/elementary/Sources/Elementary/HtmlElements.swift /Users/simon/dev/swift-projects/elementary/Sources/Elementary/HtmlTags.swift /Users/simon/dev/swift-projects/elementary/Sources/Elementary/Rendering/HtmlAsyncRenderer.swift /Users/simon/dev/swift-projects/elementary/Sources/Elementary/Rendering/HtmlTextRenderer.swift /Users/simon/dev/swift-projects/elementary/Sources/Elementary/Rendering/RenderingUtils.swift -primary-file /Users/simon/dev/swift-projects/elementary/Sources/Elementary/ServerSupport/SendOnceBox.swift -primary-file /Users/simon/dev/swift-projects/elementary/Sources/Elementary/ServerSupport/SendableAnyHTMLBox.swift -emit-dependencies-path /Users/simon/dev/swift-projects/elementary/.build/arm64-apple-macosx/debug/Elementary.build/SendOnceBox.d -emit-reference-dependencies-path /Users/simon/dev/swift-projects/elementary/.build/arm64-apple-macosx/debug/Elementary.build/SendOnceBox.swiftdeps -emit-dependencies-path /Users/simon/dev/swift-projects/elementary/.build/arm64-apple-macosx/debug/Elementary.build/SendableAnyHTMLBox.d -emit-reference-dependencies-path /Users/simon/dev/swift-projects/elementary/.build/arm64-apple-macosx/debug/Elementary.build/SendableAnyHTMLBox.swiftdeps -target arm64-apple-macosx14.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.1.sdk -I /Users/simon/dev/swift-projects/elementary/.build/arm64-apple-macosx/debug/Modules -I /Library/Developer/Toolchains/swift-6.0.2-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/simon/dev/swift-projects/elementary/.build/arm64-apple-macosx/debug/ModuleCache -swift-version 6 -Onone -D SWIFT_PACKAGE -D DEBUG -enable-upcoming-feature ExistentialAny -empty-abi-descriptor -plugin-path /Library/Developer/Toolchains/swift-6.0.2-RELEASE.xctoolchain/usr/lib/swift/host/plugins/testing -resource-dir /Library/Developer/Toolchains/swift-6.0.2-RELEASE.xctoolchain/usr/lib/swift -enable-anonymous-context-mangled-names -file-compilation-dir /Users/simon/dev/swift-projects/elementary -Xcc -isysroot -Xcc /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.1.sdk -Xcc -F -Xcc /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -Xcc -fPIC -Xcc -g -module-name Elementary -package-name elementary -plugin-path /Library/Developer/Toolchains/swift-6.0.2-RELEASE.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Library/Developer/Toolchains/swift-6.0.2-RELEASE.xctoolchain/usr/local/lib/swift/host/plugins -target-sdk-version 15.1 -target-sdk-name macosx15.1 -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/simon/dev/swift-projects/elementary/.build/arm64-apple-macosx/debug/Elementary.build/SendOnceBox.swift.o -o /Users/simon/dev/swift-projects/elementary/.build/arm64-apple-macosx/debug/Elementary.build/SendableAnyHTMLBox.swift.o -index-store-path /Users/simon/dev/swift-projects/elementary/.build/arm64-apple-macosx/debug/index/store -index-system-modules
1. Apple Swift version 6.0.2 (swift-6.0.2-RELEASE)
2. Compiling with the current language version
3. While evaluating request IRGenRequest(IR Generation for file "/Users/simon/dev/swift-projects/elementary/Sources/Elementary/ServerSupport/SendOnceBox.swift")
4. While emitting IR SIL function "@$s10Elementary11SendOnceBoxCyACyxGxncfc".
for 'init(_:)' (at /Users/simon/dev/swift-projects/elementary/Sources/Elementary/ServerSupport/SendOnceBox.swift:12: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 0x00000001066cd0d8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1 swift-frontend 0x00000001066cb8a4 llvm::sys::RunSignalHandlers() + 112
2 swift-frontend 0x00000001066cd720 SignalHandler(int) + 304
3 libsystem_platform.dylib 0x0000000193ae8184 _sigtramp + 56
4 libsystem_pthread.dylib 0x0000000193ab2f70 pthread_kill + 288
5 libsystem_c.dylib 0x00000001939bf908 abort + 128
6 libsystem_c.dylib 0x00000001939bec1c err + 0
7 swift-frontend 0x0000000106720df0 swift::irgen::emitArchetypeTypeMetadataRef(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::ArchetypeType>, swift::irgen::DynamicMetadataRequest) (.cold.6) + 0
8 swift-frontend 0x000000010158ede8 swift::irgen::emitArchetypeTypeMetadataRef(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::ArchetypeType>, swift::irgen::DynamicMetadataRequest) + 1300
9 swift-frontend 0x00000001017ce2c0 emitDirectTypeMetadataRef(swift::irgen::IRGenFunction&, swift::CanType, swift::irgen::DynamicMetadataRequest) + 2464
10 swift-frontend 0x00000001017cd180 swift::irgen::IRGenFunction::emitTypeMetadataRef(swift::CanType, swift::irgen::DynamicMetadataRequest) + 360
11 swift-frontend 0x00000001017d0be8 swift::irgen::IRGenFunction::emitTypeMetadataRefForLayout(swift::SILType, swift::irgen::DynamicMetadataRequest) + 296
12 swift-frontend 0x000000010168ba88 swift::irgen::IRGenFunction::emitValueWitnessTableRef(swift::SILType, swift::irgen::DynamicMetadataRequest, llvm::Value**) + 180
13 swift-frontend 0x000000010168b9c8 swift::irgen::IRGenFunction::emitValueWitnessTableRef(swift::SILType, llvm::Value**) + 32
14 swift-frontend 0x00000001016a6938 swift::irgen::IRGenFunction::emitValueWitnessFunctionRef(swift::SILType, llvm::Value*&, swift::irgen::ValueWitness) + 260
15 swift-frontend 0x00000001016a8650 swift::irgen::emitGetEnumTagSinglePayloadCall(swift::irgen::IRGenFunction&, swift::SILType, llvm::Value*, swift::irgen::Address) + 388
16 swift-frontend 0x000000010163e460 (anonymous namespace)::SinglePayloadEnumImplStrategy::testEnumContainsPayload(swift::irgen::IRGenFunction&, swift::irgen::Address, swift::SILType) const + 496
17 swift-frontend 0x000000010163faac (anonymous namespace)::SinglePayloadEnumImplStrategy::emitIndirectInitialize(swift::irgen::IRGenFunction&, swift::irgen::Address, swift::irgen::Address, swift::SILType, swift::IsTake_t, bool) const + 280
18 swift-frontend 0x000000010163b304 (anonymous namespace)::SinglePayloadEnumImplStrategy::initializeWithTake(swift::irgen::IRGenFunction&, swift::irgen::Address, swift::irgen::Address, swift::SILType, bool) const + 316
19 swift-frontend 0x0000000101626c10 (anonymous namespace)::EnumTypeInfoBase<swift::irgen::WitnessSizedTypeInfo<(anonymous namespace)::NonFixedEnumTypeInfo>>::initializeWithTake(swift::irgen::IRGenFunction&, swift::irgen::Address, swift::irgen::Address, swift::SILType, bool) const + 68
20 swift-frontend 0x00000001016e1b5c swift::irgen::RecordTypeInfoImpl<(anonymous namespace)::NonFixedStructTypeInfo, swift::irgen::WitnessSizedTypeInfo<(anonymous namespace)::NonFixedStructTypeInfo>, (anonymous namespace)::StructFieldInfo, false>::initializeWithTake(swift::irgen::IRGenFunction&, swift::irgen::Address, swift::irgen::Address, swift::SILType, bool) const + 1140
21 swift-frontend 0x00000001016e1a7c swift::irgen::RecordTypeInfoImpl<(anonymous namespace)::NonFixedStructTypeInfo, swift::irgen::WitnessSizedTypeInfo<(anonymous namespace)::NonFixedStructTypeInfo>, (anonymous namespace)::StructFieldInfo, false>::initializeWithTake(swift::irgen::IRGenFunction&, swift::irgen::Address, swift::irgen::Address, swift::SILType, bool) const + 916
22 swift-frontend 0x00000001017db500 void llvm::function_ref<void (swift::irgen::IRGenFunction&, swift::irgen::Address, swift::irgen::Address, swift::SILType, swift::irgen::TypeInfo const&)>::callback_fn<swift::irgen::IRGenModule::getOrCreateOutlinedInitializeWithTakeFunction(swift::SILType, swift::irgen::TypeInfo const&, swift::irgen::OutliningMetadataCollector const&)::$_1>(long, swift::irgen::IRGenFunction&, swift::irgen::Address, swift::irgen::Address, swift::SILType, swift::irgen::TypeInfo const&) + 304
23 swift-frontend 0x00000001017dbc10 void llvm::function_ref<void (swift::irgen::IRGenFunction&)>::callback_fn<swift::irgen::IRGenModule::getOrCreateOutlinedCopyAddrHelperFunction(swift::SILType, swift::irgen::TypeInfo const&, swift::irgen::OutliningMetadataCollector const&, llvm::StringRef, llvm::function_ref<void (swift::irgen::IRGenFunction&, swift::irgen::Address, swift::irgen::Address, swift::SILType, swift::irgen::TypeInfo const&)>)::$_5>(long, swift::irgen::IRGenFunction&) + 228
24 swift-frontend 0x0000000101610620 swift::irgen::IRGenModule::getOrCreateHelperFunction(llvm::StringRef, llvm::Type*, llvm::ArrayRef<llvm::Type*>, llvm::function_ref<void (swift::irgen::IRGenFunction&)>, bool, bool, bool) + 348
25 swift-frontend 0x00000001017d86b0 swift::irgen::IRGenModule::getOrCreateOutlinedCopyAddrHelperFunction(swift::SILType, swift::irgen::TypeInfo const&, swift::irgen::OutliningMetadataCollector const&, llvm::StringRef, llvm::function_ref<void (swift::irgen::IRGenFunction&, swift::irgen::Address, swift::irgen::Address, swift::SILType, swift::irgen::TypeInfo const&)>) + 216
26 swift-frontend 0x00000001017d7e00 swift::irgen::IRGenModule::getOrCreateOutlinedInitializeWithTakeFunction(swift::SILType, swift::irgen::TypeInfo const&, swift::irgen::OutliningMetadataCollector const&) + 484
27 swift-frontend 0x00000001017d7ae4 swift::irgen::OutliningMetadataCollector::emitCallToOutlinedCopy(swift::irgen::Address, swift::irgen::Address, swift::SILType, swift::irgen::TypeInfo const&, swift::IsInitialization_t, swift::IsTake_t) const + 456
28 swift-frontend 0x00000001017db230 void llvm::function_ref<void (swift::irgen::OutliningMetadataCollector&)>::callback_fn<swift::irgen::TypeInfo::callOutlinedCopy(swift::irgen::IRGenFunction&, swift::irgen::Address, swift::irgen::Address, swift::SILType, swift::IsInitialization_t, swift::IsTake_t) const::$_0>(long, swift::irgen::OutliningMetadataCollector&) + 152
29 swift-frontend 0x00000001017d7710 swift::irgen::TypeInfo::withWitnessableMetadataCollector(swift::irgen::IRGenFunction&, swift::SILType, swift::irgen::LayoutIsNeeded_t, swift::irgen::DeinitIsNeeded_t, llvm::function_ref<void (swift::irgen::OutliningMetadataCollector&)>) const + 364
30 swift-frontend 0x00000001017d77cc swift::irgen::TypeInfo::callOutlinedCopy(swift::irgen::IRGenFunction&, swift::irgen::Address, swift::irgen::Address, swift::SILType, swift::IsInitialization_t, swift::IsTake_t) const + 112
31 swift-frontend 0x00000001016e1934 swift::irgen::RecordTypeInfoImpl<(anonymous namespace)::NonFixedStructTypeInfo, swift::irgen::WitnessSizedTypeInfo<(anonymous namespace)::NonFixedStructTypeInfo>, (anonymous namespace)::StructFieldInfo, false>::initializeWithTake(swift::irgen::IRGenFunction&, swift::irgen::Address, swift::irgen::Address, swift::SILType, bool) const + 588
32 swift-frontend 0x000000010176aa20 (anonymous namespace)::IRGenSILFunction::visitSILBasicBlock(swift::SILBasicBlock*) + 39956
33 swift-frontend 0x000000010175fc70 (anonymous namespace)::IRGenSILFunction::emitSILFunction() + 9204
34 swift-frontend 0x000000010175d2e8 swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 1592
35 swift-frontend 0x00000001015fdaa4 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&) + 740
36 swift-frontend 0x000000010170f8f8 swift::IRGenRequest::evaluate(swift::Evaluator&, swift::IRGenDescriptor) const + 2172
37 swift-frontend 0x000000010175c7a4 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 + 200
38 swift-frontend 0x0000000101717fb4 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'()) + 212
39 swift-frontend 0x0000000101711960 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**) + 208
40 swift-frontend 0x000000010121b90c 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>>>) + 156
41 swift-frontend 0x0000000101218340 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*) + 1416
42 swift-frontend 0x00000001012177a0 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 656
43 swift-frontend 0x00000001012234ac withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) + 160
44 swift-frontend 0x0000000101219678 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 708
45 swift-frontend 0x0000000101218d4c swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2344
46 swift-frontend 0x000000010102f384 swift::mainEntry(int, char const**) + 3096
47 dyld 0x0000000193730274 start + 2840
Expected behavior
As a user I want no crashers so that humanity can use the Synchronization
module without fear ; )
Environment
Apple Swift version 6.0.2 (swift-6.0.2-RELEASE)
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.A deviation from expected or documented behavior. Also: expected but undesirable behavior.concurrencyFeature: umbrella label for concurrency language featuresFeature: umbrella label for concurrency language featurescrashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of software