Open gdalle opened 8 months ago
The DiffResults documentation clearly states that whenever a DiffResult object is used, it must be realiased at the end of the function call:
DiffResult
result = do_stuff!(result, args...)
See for instance the docstrings in https://juliadiff.org/DiffResults.jl/stable/#Mutating-a-DiffResult, or the issue DiffResults#17
This is not done by ForwardDiff, for instance here:
https://github.com/JuliaDiff/ForwardDiff.jl/blob/42b1554493f04a7e3d2606f328e2a0e365bf8f69/src/gradient.jl#L35-L44
Am I right in deducing that it can lead to incorrectness?
See also https://github.com/JuliaDiff/ReverseDiff.jl/issues/251
I can't manage to get an actual bug out of this, presumably because the StaticArrays extension of ForwardDiff overloads the vulnerable parts I've tried. But for ReverseDiff this does lead to wrong behavior
The DiffResults documentation clearly states that whenever a
DiffResult
object is used, it must be realiased at the end of the function call:See for instance the docstrings in https://juliadiff.org/DiffResults.jl/stable/#Mutating-a-DiffResult, or the issue DiffResults#17
This is not done by ForwardDiff, for instance here:
https://github.com/JuliaDiff/ForwardDiff.jl/blob/42b1554493f04a7e3d2606f328e2a0e365bf8f69/src/gradient.jl#L35-L44
Am I right in deducing that it can lead to incorrectness?