-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
AutoDiffbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.run-time crashBug → crash: Swift code crashed during executionBug → crash: Swift code crashed during executionruntimeThe Swift RuntimeThe Swift Runtimeswift 5.9
Description
Description
Recently we fixed an issue in the Autodiff runtime due to which PBs w/ loops used to leak memory. A fix for the issue was merged in #67944. While validating the fix on our internal test suite we uncovered another memory related bug (a double free) because of which certain pullbacks w/ loops can segfault.
Below is a minimal reproducer for the issue.
import _Differentiation
@differentiable(reverse) func B(x: Float) -> Float {
var y = x + 1
for _ in 0 ..< 1 {}
return y
}
func f() {
let (_, pb) = valueWithPullback(at: 1.0, of: B)
pb(21.0)
}
f()
Running the above program leads to a segfault.
Expected Behavior
The program should not segfault and pullback of B
should be runnable multiple times.
Metadata
Metadata
Assignees
Labels
AutoDiffbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.run-time crashBug → crash: Swift code crashed during executionBug → crash: Swift code crashed during executionruntimeThe Swift RuntimeThe Swift Runtimeswift 5.9