-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed
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.crashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of softwaretriage neededThis issue needs more specific labelsThis issue needs more specific labels
Description
Description
Swift 6.2 compiler is crashing on some code where I am changing code from using a Tuple to InlineArray. The changes are pretty straight forward.
Reproduction
I have a private repo I can add swift maintainers to with a repro: https://github.com/toffaletti/swift-tenthash/pull/2
This code compiled when state was declared as a Tuple:
func mix(_ state: inout State) {
for rotation in Self.rotations {
state.0 &+= state.2
state.1 &+= state.3
state.2 = ((state.2 << rotation.0) | state.2 >> (64 - rotation.0)) ^ state.0
state.3 = ((state.3 << rotation.1) | state.3 >> (64 - rotation.1)) ^ state.1
swap(&state.0, &state.1)
}
}
This code crashes with state as InlineArray.
func mix(_ state: inout State) {
for i in Self.rotations.indices {
let rotation = Self.rotations[i]
state[0] &+= state[2]
state[1] &+= state[3]
state[2] = ((state[2] << rotation.0) | state[2] >> (64 - rotation.0)) ^ state[0]
state[3] = ((state[3] << rotation.1) | state[3] >> (64 - rotation.1)) ^ state[1]
swap(&state[0], &state[1])
}
}
Stack dump
❯ swift test
[1/1] Planning build
Building for debugging...
error: compile command failed due to signal 6 (use -v to see invocation)
Assertion failed: (isCallToStandardLibrarySwap(CE, Ctx)), function canReplaceWithCallToCollectionSwapAt, file DiagnoseStaticExclusivity.cpp, line 403.
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0. Program arguments: /Users/jason/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend -frontend -c -primary-file /Users/jason/Code/swift-tenthash/Sources/TentHash/TentHash.swift -emit-dependencies-path /Users/jason/Code/swift-tenthash/.build/arm64-apple-macosx/debug/TentHash.build/TentHash.d -emit-reference-dependencies-path /Users/jason/Code/swift-tenthash/.build/arm64-apple-macosx/debug/TentHash.build/TentHash.swiftdeps -serialize-diagnostics-path /Users/jason/Code/swift-tenthash/.build/arm64-apple-macosx/debug/TentHash.build/TentHash.dia -target arm64-apple-macosx26.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX26.0.sdk -I /Users/jason/Code/swift-tenthash/.build/arm64-apple-macosx/debug/Modules -I /Users/jason/Library/Developer/Toolchains/swift-6.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 -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/PrivateFrameworks -color-diagnostics -Xcc -fcolor-diagnostics -enable-testing -g -debug-info-format=dwarf -dwarf-version=5 -module-cache-path /Users/jason/Code/swift-tenthash/.build/arm64-apple-macosx/debug/ModuleCache -swift-version 6 -Onone -D SWIFT_PACKAGE -D DEBUG -D SWIFT_MODULE_RESOURCE_BUNDLE_UNAVAILABLE -empty-abi-descriptor -plugin-path /Users/jason/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/lib/swift/host/plugins/testing -enable-anonymous-context-mangled-names -file-compilation-dir /Users/jason/Code/swift-tenthash -Xcc -isysroot -Xcc /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX26.0.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 -no-auto-bridging-header-chaining -module-name TentHash -package-name swift_tenthash -in-process-plugin-server-path /Users/jason/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/lib/swift/host/libSwiftInProcPluginServer.dylib -plugin-path /Users/jason/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Users/jason/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/local/lib/swift/host/plugins -target-sdk-version 26.0 -target-sdk-name macosx26.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/jason/Code/swift-tenthash/.build/arm64-apple-macosx/debug/TentHash.build/TentHash.swift.o -index-store-path /Users/jason/Code/swift-tenthash/.build/arm64-apple-macosx/debug/index/store -index-system-modules
1. Apple Swift version 6.2 (swift-6.2-RELEASE)
2. Compiling with the current language version
3. While evaluating request ExecuteSILPipelineRequest(Run pipelines { Mandatory Diagnostic Passes + Enabling Optimization Passes } on SIL for TentHash)
4. While running pass #72 SILModuleTransform "DiagnoseStaticExclusivity".
#0 0x000000010a1f0f18 (/Users/jason/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x1059dcf18)
#1 0x000000010a1ef644 (/Users/jason/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x1059db644)
#2 0x000000010a1f1560 (/Users/jason/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x1059dd560)
#3 0x000000019783e744 (/usr/lib/system/libsystem_platform.dylib+0x1804e2744)
#4 0x0000000197834888 (/usr/lib/system/libsystem_pthread.dylib+0x1804d8888)
#5 0x000000019773a7fc (/usr/lib/system/libsystem_c.dylib+0x1803de7fc)
#6 0x0000000197739a30 (/usr/lib/system/libsystem_c.dylib+0x1803dda30)
#7 0x000000010a230b08 (/Users/jason/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x105a1cb08)
#8 0x00000001053963c4 (/Users/jason/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x100b823c4)
#9 0x00000001053942f0 (/Users/jason/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x100b802f0)
#10 0x000000010543f7c4 (/Users/jason/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x100c2b7c4)
#11 0x0000000105441be4 (/Users/jason/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x100c2dbe4)
#12 0x000000010543c5ec (/Users/jason/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x100c285ec)
#13 0x000000010543c56c (/Users/jason/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x100c2856c)
#14 0x0000000105461dac (/Users/jason/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x100c4ddac)
#15 0x00000001054437b8 (/Users/jason/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x100c2f7b8)
#16 0x000000010543c7dc (/Users/jason/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x100c287dc)
#17 0x0000000105444d8c (/Users/jason/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x100c30d8c)
#18 0x0000000104ce9d38 (/Users/jason/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x1004d5d38)
#19 0x0000000104aa8fa4 (/Users/jason/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x100294fa4)
#20 0x0000000104aa8604 (/Users/jason/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x100294604)
#21 0x0000000104ab4dc8 (/Users/jason/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x1002a0dc8)
#22 0x0000000104aaa3fc (/Users/jason/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x1002963fc)
#23 0x0000000104aa9bb8 (/Users/jason/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x100295bb8)
#24 0x000000010484d6b4 (/Users/jason/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x1000396b4)
#25 0x000000019746dd54
[17/70] Emitting module ArgumentParserToolInfo
error: fatalError
Expected behavior
I expect the code to compile.
Environment
Apple Swift version 6.2 (swift-6.2-RELEASE)
Target: arm64-apple-macosx26.0
Build config: +assertions
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.crashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of softwaretriage neededThis issue needs more specific labelsThis issue needs more specific labels