Skip to content

Swift compiler crash when mapping childrens of a Mirror to an Any array member var #82101

Open
@Matthdonau

Description

@Matthdonau

Description

Playing around with parameter packs I found the Swift compiler crashing when trying to compile program attached below with "swift build"

Reproduction

import Foundation

@available(macOS 14.0.0, *)
class GenericVariant<each T>
{
    private var types: (repeat (each T).Type)
    private var lastStored : Int?
    private var tupleElements : [Any]

    init()
    {
        // Setup types given as type parameter pack.
        types = (repeat (each T).self)
        let mirror: Mirror = Mirror(reflecting: types)
        tupleElements = mirror.children.map({ $0.value })
    }

}

Stack dump

Building for debugging...
error: compile command failed due to signal 11 (use -v to see invocation)
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 -primary-file /Users/mad/Desktop/Verwaltung/Programs/swift/test/Sources/crash.swift /Users/mad/Desktop/Verwaltung/Programs/swift/test/Sources/mytestapp.swift /Users/mad/Desktop/Verwaltung/Programs/swift/test/Sources/variant.swift -emit-dependencies-path /Users/mad/Desktop/Verwaltung/Programs/swift/test/.build/arm64-apple-macosx/debug/MyTestApp.build/crash.d -emit-reference-dependencies-path /Users/mad/Desktop/Verwaltung/Programs/swift/test/.build/arm64-apple-macosx/debug/MyTestApp.build/crash.swiftdeps -target arm64-apple-macosx10.13 -Xllvm -aarch64-use-tbi -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk -I /Users/mad/Desktop/Verwaltung/Programs/swift/test/.build/arm64-apple-macosx/debug/Modules -I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/PrivateFrameworks -color-diagnostics -enable-testing -g -debug-info-format=dwarf -dwarf-version=4 -module-cache-path /Users/mad/Desktop/Verwaltung/Programs/swift/test/.build/arm64-apple-macosx/debug/ModuleCache -swift-version 6 -Onone -D SWIFT_PACKAGE -D DEBUG -new-driver-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-driver -entry-point-function-name MyTestApp_main -empty-abi-descriptor -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift -enable-anonymous-context-mangled-names -file-compilation-dir /Users/mad/Desktop/Verwaltung/Programs/swift/test -Xcc -isysroot -Xcc /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk -Xcc -F -Xcc /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -Xcc -F -Xcc /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/PrivateFrameworks -Xcc -fPIC -Xcc -g -module-name MyTestApp -package-name test -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/mad/Desktop/Verwaltung/Programs/swift/test/.build/arm64-apple-macosx/debug/MyTestApp.build/crash.swift.o -index-store-path /Users/mad/Desktop/Verwaltung/Programs/swift/test/.build/arm64-apple-macosx/debug/index/store -index-system-modules
1.	Apple Swift version 6.1 (swiftlang-6.1.0.110.21 clang-1700.0.13.3)
2.	Compiling with the current language version
3.	While evaluating request IRGenRequest(IR Generation for file "/Users/mad/Desktop/Verwaltung/Programs/swift/test/Sources/crash.swift")
4.	While emitting IR SIL function "@$s9MyTestApp14GenericVariantCACyxxQp_QPGycfc".
 for 'init()' (at /Users/mad/Desktop/Verwaltung/Programs/swift/test/Sources/crash.swift:10:5)
 #0 0x000000010a822c28 (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend+0x1064aec28)
 #1 0x000000010a820a60 (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend+0x1064aca60)
 #2 0x000000010a823264 (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend+0x1064af264)
 #3 0x0000000184148624 (/usr/lib/system/libsystem_platform.dylib+0x1804ac624)
 #4 0x0000000104c54c10 (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend+0x1008e0c10)
 #5 0x0000000104cf4d78 (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend+0x100980d78)
 #6 0x0000000104cde38c (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend+0x10096a38c)
 #7 0x0000000104cda0e0 (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend+0x1009660e0)
 #8 0x0000000104afd560 (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend+0x100789560)
 #9 0x0000000104c8b9fc (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend+0x1009179fc)
#10 0x0000000104cd933c (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend+0x10096533c)
#11 0x0000000104c94f28 (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend+0x100920f28)
#12 0x0000000104c8e688 (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend+0x10091a688)
#13 0x0000000104679af0 (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend+0x100305af0)
#14 0x000000010467507c (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend+0x10030107c)
#15 0x00000001046740a8 (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend+0x1003000a8)
#16 0x0000000104677654 (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend+0x100303654)
#17 0x0000000104675fd8 (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend+0x100301fd8)
#18 0x00000001045fa0bc (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend+0x1002860bc)
#19 0x0000000183d6eb98

Expected behavior

No 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

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.crashBug: A crash, i.e., an abnormal termination of softwaretriage neededThis issue needs more specific labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions