JuliaDiff / JuliaDiff/ForwardDiff.jl

DiffResults objects are not re-aliased properly

Open
#696 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Julia
Stars
1k
Forks
160
PR merge metrics
No merged PRs in 30d

Description

The DiffResults documentation clearly states that whenever a DiffResult object is used, it must be realiased at the end of the function call:

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?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/gradient.jl at the referenced lines 35-44 and read the DiffResults documentation on mutating a DiffResult, along with DiffResults#17. Trace whether ForwardDiff's current handling can retain stale aliases or produce incorrect results; done means the behavior is confirmed or disproved and the required change is clearly identified.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.