[AutoDiff] Runtime EXC_BAD_ACCESS when running a pullback in certain cases. #73526
Labels
AutoDiff
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
run-time crash
Bug → crash: Swift code crashed during execution
triage needed
This issue needs more specific labels
Description
The code below generates a runtime
EXC_BAD_ACCESS
when executed.Reproduction
Copy and paste the following code into a new project, and build in Debug mode.
If run in Xcode, the error will be highlighted in line 19, which contains
b.append(O<G>(v: y[i]))
. Here, it will indicate an "index out of range" error.If built via
swift build
and executed inlldb
, anEXC_BAD_ACCESS
will be triggered with an attempt to access0x0
. The stack trace for this is listed below.Expected behavior
The program should print:
(value: 27.0, gradient: i2.R.TangentVector(a: 3.0))
and exit with an exit code of 0.
Here,
i2
is the name of the current project.Environment
M1 Mac
Every toolchain I've tried exhibits this, from 2023-07-10a nightly all the way to 2024-05-01a. I can even reproduce this with the 6.0 2024-04-29a snapshot.
Additional information
Stack trace when run in
lldb
. Note that the executable is simply calleda
.If we perform the append operation via
b = b + [O<G>(v: y[i])]
, which is commented out in line 20, then the runtime error will not occur.The text was updated successfully, but these errors were encountered: