-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
Description
the program below crashes the compiler; this is somehow caused by the sensors.append
line.
changing the members of Sensor
fixes this; eg if we remove either of displayName
or quarantineDuration
or change the second property's type to DateComponents
, it compiles without crashing.
this only seems to work for some types, though: changing the quarantineDuration
type to a Double
eg does not fix the crash.
Reproduction
protocol AnySensor: Hashable, Sendable {}
struct Sensor<Sample>: AnySensor {
let displayName: String
let dataQuarantineDuration: Duration
}
func requestAccess<each Sample>(to sensor: repeat Sensor<each Sample>) {
var sensors: [any AnySensor] = []
for sensor in repeat each sensor {
sensors.append(sensor)
}
}
Stack dump
Cannot mangle free-standing archetype: (element_archetype_type address=0x13f5c02d8 conforms_to="Swift.(file).Copyable" conforms_to="Swift.(file).Escapable" opened_element_id="74E507D4-71ED-11F0-8099-7E17E33D3077")
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0. Program arguments: /Applications/Xcode-16.4.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -c -primary-file /Users/lukas/temp/swift_crash_repro/Sources/swift_crash_repro/SensorKit.swift -emit-dependencies-path /Users/lukas/Library/Developer/Xcode/DerivedData/swift_crash_repro-fftkfjtenkpihxfyqkwotgfdwllv/Build/Intermediates.noindex/swift_crash_repro.build/Debug-iphoneos/swift_crash_repro.build/Objects-normal/arm64/SensorKit.d -emit-const-values-path /Users/lukas/Library/Developer/Xcode/DerivedData/swift_crash_repro-fftkfjtenkpihxfyqkwotgfdwllv/Build/Intermediates.noindex/swift_crash_repro.build/Debug-iphoneos/swift_crash_repro.build/Objects-normal/arm64/SensorKit.swiftconstvalues -emit-reference-dependencies-path /Users/lukas/Library/Developer/Xcode/DerivedData/swift_crash_repro-fftkfjtenkpihxfyqkwotgfdwllv/Build/Intermediates.noindex/swift_crash_repro.build/Debug-iphoneos/swift_crash_repro.build/Objects-normal/arm64/SensorKit.swiftdeps -serialize-diagnostics-path /Users/lukas/Library/Developer/Xcode/DerivedData/swift_crash_repro-fftkfjtenkpihxfyqkwotgfdwllv/Build/Intermediates.noindex/swift_crash_repro.build/Debug-iphoneos/swift_crash_repro.build/Objects-normal/arm64/SensorKit.dia -target arm64-apple-ios17.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -stack-check -sdk /Applications/Xcode-16.4.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS18.5.sdk -I /Users/lukas/Library/Developer/Xcode/DerivedData/swift_crash_repro-fftkfjtenkpihxfyqkwotgfdwllv/Build/Products/Debug-iphoneos -I /Applications/Xcode-16.4.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/lib -F /Users/lukas/Library/Developer/Xcode/DerivedData/swift_crash_repro-fftkfjtenkpihxfyqkwotgfdwllv/Build/Products/Debug-iphoneos -F /Applications/Xcode-16.4.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Frameworks -F /Applications/Xcode-16.4.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS18.5.sdk/Developer/Library/Frameworks -no-color-diagnostics -enable-testing -g -debug-info-format=dwarf -dwarf-version=4 -module-cache-path /Users/lukas/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -profile-generate -profile-coverage-mapping -swift-version 6 -enforce-exclusivity=checked -Onone -D SWIFT_PACKAGE -D DEBUG -D Xcode -serialize-debugging-options -const-gather-protocols-file /Users/lukas/Library/Developer/Xcode/DerivedData/swift_crash_repro-fftkfjtenkpihxfyqkwotgfdwllv/Build/Intermediates.noindex/swift_crash_repro.build/Debug-iphoneos/swift_crash_repro.build/Objects-normal/arm64/swift_crash_repro_const_extract_protocols.json -enable-experimental-feature DebugDescriptionMacro -empty-abi-descriptor -plugin-path /Applications/Xcode-16.4.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/plugins/testing -validate-clang-modules-once -clang-build-session-file /Users/lukas/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation -Xcc -working-directory -Xcc /Users/lukas/temp/swift_crash_repro/.swiftpm/xcode -resource-dir /Applications/Xcode-16.4.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift -enable-anonymous-context-mangled-names -file-compilation-dir /Users/lukas/temp/swift_crash_repro/.swiftpm/xcode -Xcc -ivfsstatcache -Xcc /Users/lukas/Library/Developer/Xcode/DerivedData/SDKStatCaches.noindex/iphoneos18.5-22F76-551a2dbffca57c57d7016a01ac60a780.sdkstatcache -Xcc -I/Users/lukas/Library/Developer/Xcode/DerivedData/swift_crash_repro-fftkfjtenkpihxfyqkwotgfdwllv/Build/Intermediates.noindex/swift_crash_repro.build/Debug-iphoneos/swift_crash_repro.build/swift-overrides.hmap -Xcc -I/Users/lukas/Library/Developer/Xcode/DerivedData/swift_crash_repro-fftkfjtenkpihxfyqkwotgfdwllv/Build/Products/Debug-iphoneos/include -Xcc -I/Users/lukas/Library/Developer/Xcode/DerivedData/swift_crash_repro-fftkfjtenkpihxfyqkwotgfdwllv/Build/Intermediates.noindex/swift_crash_repro.build/Debug-iphoneos/swift_crash_repro.build/DerivedSources-normal/arm64 -Xcc -I/Users/lukas/Library/Developer/Xcode/DerivedData/swift_crash_repro-fftkfjtenkpihxfyqkwotgfdwllv/Build/Intermediates.noindex/swift_crash_repro.build/Debug-iphoneos/swift_crash_repro.build/DerivedSources/arm64 -Xcc -I/Users/lukas/Library/Developer/Xcode/DerivedData/swift_crash_repro-fftkfjtenkpihxfyqkwotgfdwllv/Build/Intermediates.noindex/swift_crash_repro.build/Debug-iphoneos/swift_crash_repro.build/DerivedSources -Xcc -DSWIFT_PACKAGE -Xcc -DDEBUG=1 -module-name swift_crash_repro -package-name swift_crash_repro -frontend-parseable-output -disable-clang-spi -target-sdk-version 18.5 -target-sdk-name iphoneos18.5 -external-plugin-path /Applications/Xcode-16.4.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/lib/swift/host/plugins#/Applications/Xcode-16.4.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode-16.4.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/local/lib/swift/host/plugins#/Applications/Xcode-16.4.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/swift-plugin-server -in-process-plugin-server-path /Applications/Xcode-16.4.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/libSwiftInProcPluginServer.dylib -plugin-path /Applications/Xcode-16.4.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Applications/Xcode-16.4.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/local/lib/swift/host/plugins -parse-as-library -o /Users/lukas/Library/Developer/Xcode/DerivedData/swift_crash_repro-fftkfjtenkpihxfyqkwotgfdwllv/Build/Intermediates.noindex/swift_crash_repro.build/Debug-iphoneos/swift_crash_repro.build/Objects-normal/arm64/SensorKit.o -index-unit-output-path /swift_crash_repro.build/Debug-iphoneos/swift_crash_repro.build/Objects-normal/arm64/SensorKit.o -index-store-path /Users/lukas/Library/Developer/Xcode/DerivedData/swift_crash_repro-fftkfjtenkpihxfyqkwotgfdwllv/Index.noindex/DataStore -index-system-modules
1. Apple Swift version 6.1.2 (swiftlang-6.1.2.1.2 clang-1700.0.13.5)
2. Compiling with the current language version
3. While evaluating request IRGenRequest(IR Generation for file "/Users/lukas/temp/swift_crash_repro/Sources/swift_crash_repro/SensorKit.swift")
4. While emitting IR SIL function "@$s17swift_crash_repro13requestAccess2toyAA6SensorVyxGxQp_tRvzlF".
for 'requestAccess(to:)' (at /Users/lukas/temp/swift_crash_repro/Sources/swift_crash_repro/SensorKit.swift:20:1)
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 0x0000000106c9ae24 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1 swift-frontend 0x0000000106c98c5c llvm::sys::RunSignalHandlers() + 112
2 swift-frontend 0x0000000106c9b460 SignalHandler(int) + 360
3 libsystem_platform.dylib 0x0000000184080624 _sigtramp + 56
4 libsystem_pthread.dylib 0x000000018404688c pthread_kill + 296
5 libsystem_c.dylib 0x0000000183f4fc60 abort + 124
6 swift-frontend 0x0000000102230280 swift::Mangle::ASTMangler::appendType(swift::Type, swift::GenericSignature, swift::ValueDecl const*) + 4928
7 swift-frontend 0x000000010223630c swift::Mangle::ASTMangler::appendBoundGenericArgs(swift::Type, swift::GenericSignature, bool&, swift::ValueDecl const*) + 580
8 swift-frontend 0x000000010222fa64 swift::Mangle::ASTMangler::appendType(swift::Type, swift::GenericSignature, swift::ValueDecl const*) + 2852
9 swift-frontend 0x0000000101129bb8 swift::irgen::IRGenMangler::withSymbolicReferences(swift::irgen::IRGenModule&, llvm::function_ref<void ()>) + 364
10 swift-frontend 0x0000000101129e2c swift::irgen::IRGenMangler::mangleTypeForReflection(swift::irgen::IRGenModule&, swift::CanGenericSignature, swift::CanType) + 276
11 swift-frontend 0x000000010109dbd4 getTypeRefImpl(swift::irgen::IRGenModule&, swift::CanType, swift::CanGenericSignature, swift::irgen::MangledTypeRefRole) + 1576
12 swift-frontend 0x00000001010a3758 ReflectionMetadataBuilder::addLoweredTypeRef(swift::SILType, swift::CanGenericSignature, swift::irgen::MangledTypeRefRole) + 236
13 swift-frontend 0x00000001010a3090 ReflectionMetadataBuilder::emit(std::__1::optional<llvm::function_ref<llvm::Constant* (swift::irgen::IRGenModule&, swift::irgen::ConstantInit)>>, char const*) + 48
14 swift-frontend 0x000000010109f1dc swift::irgen::IRGenModule::getAddrOfBoxDescriptor(swift::SILType, swift::CanGenericSignature) + 192
15 swift-frontend 0x000000010101b04c (anonymous namespace)::FixedBoxTypeInfoBase::allocate(swift::irgen::IRGenFunction&, swift::SILType, swift::GenericEnvironment*, llvm::Twine const&) const + 468
16 swift-frontend 0x000000010100f450 swift::irgen::emitAllocateExistentialBoxInBuffer(swift::irgen::IRGenFunction&, swift::SILType, swift::irgen::Address, swift::GenericEnvironment*, llvm::Twine const&, bool) + 288
17 swift-frontend 0x0000000100fd9294 swift::irgen::emitAllocateBoxedOpaqueExistentialBuffer(swift::irgen::IRGenFunction&, swift::SILType, swift::SILType, swift::irgen::Address, swift::GenericEnvironment*, bool) + 672
18 swift-frontend 0x0000000101168624 (anonymous namespace)::IRGenSILFunction::visitSILBasicBlock(swift::SILBasicBlock*) + 67844
19 swift-frontend 0x0000000101156614 (anonymous namespace)::IRGenSILFunction::emitSILFunction() + 15860
20 swift-frontend 0x0000000101152368 swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 2788
21 swift-frontend 0x0000000100f757e0 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&) + 2044
22 swift-frontend 0x0000000101103c84 swift::IRGenRequest::evaluate(swift::Evaluator&, swift::IRGenDescriptor) const + 4296
23 swift-frontend 0x00000001011515c4 swift::SimpleRequest<swift::IRGenRequest, swift::GeneratedModule (swift::IRGenDescriptor), (swift::RequestFlags)17>::evaluateRequest(swift::IRGenRequest const&, swift::Evaluator&) + 180
24 swift-frontend 0x000000010110d1b0 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'()) + 812
25 swift-frontend 0x0000000101106910 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**) + 176
26 swift-frontend 0x0000000100af1af0 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
27 swift-frontend 0x0000000100aed07c 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*) + 2108
28 swift-frontend 0x0000000100aec0a8 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1036
29 swift-frontend 0x0000000100aef654 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1764
30 swift-frontend 0x0000000100aedfd8 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3716
31 swift-frontend 0x0000000100a720bc swift::mainEntry(int, char const**) + 5428
32 dyld 0x0000000183ca6b98 start + 6076
Expected behavior
this should compile
Environment
swift-driver version: 1.120.5 Apple Swift version 6.1.2 (swiftlang-6.1.2.1.2 clang-1700.0.13.5)
Target: arm64-apple-macosx15.0
Additional information
#73690 has the same error ("Cannot mangle free-standing archetype"), but the stack trace there is different from what i'm running into (no key paths are involved in the crash here), so i don't think this is a duplicate?