-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed
Labels
AutoDiffCodeGenarmArchitecture: any ARMArchitecture: any ARMarm64Architecture: arm64 (aarch64) — any 64-bit ARMArchitecture: arm64 (aarch64) — any 64-bit ARMbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of softwareoptimized onlyFlag: An issue whose reproduction requires optimized compilationFlag: An issue whose reproduction requires optimized compilationrun-time crashBug → crash: Swift code crashed during executionBug → crash: Swift code crashed during executionswift 5.9
Description
Description
This appears to affect M1 machines only; I did not see this crash on an x86 Mac.
Steps to reproduce
The following program crashes at runtime when built in Release mode and run. For a command-line build, swift run -c release
should be sufficient.
import _Differentiation
func r(a: Float) -> Float {for _ in 0 ..< 1 {}; return a}
func p() {gradient(at: 2, of: r)}
for _ in 0 ..< 2 {p()}
Expected behavior
The program should exit with an exit code of 0.
Environment
- Swift compiler version info: This fails with Toolchains 2022-10-08a up until 2023-05-25a. Toolchains 2022-09-24a don't appear to exhibit this issue (I haven't narrowed down the date range between those two any further at this time).
- Xcode version info: 14.2
- Deployment target: M1. (Note: an x86 Mac does not appear to exhibit this crash, even with the 2023-05-25a toolchain).
Additional context
The for
loop in line 2 does not do anything, but is required to replicate this issue.
Running the for
loop in line 4 with a range of 0 ..< 1
instead of 0 ..< 2
causes the crash to no longer occur.
Metadata
Metadata
Assignees
Labels
AutoDiffCodeGenarmArchitecture: any ARMArchitecture: any ARMarm64Architecture: arm64 (aarch64) — any 64-bit ARMArchitecture: arm64 (aarch64) — any 64-bit ARMbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of softwareoptimized onlyFlag: An issue whose reproduction requires optimized compilationFlag: An issue whose reproduction requires optimized compilationrun-time crashBug → crash: Swift code crashed during executionBug → crash: Swift code crashed during executionswift 5.9