-
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.
Description
Previous ID | SR-13945 |
Radar | rdar://problem/72160850 |
Original Reporter | @marcrasi |
Type | Bug |
Status | Closed |
Resolution | Done |
Additional Detail from JIRA
Votes | 0 |
Component/s | |
Labels | Bug, AutoDiff |
Assignee | @marcrasi |
Priority | Medium |
md5: 8e8401d9c9641d0f9a1d5a8d944d8be4
Issue Description:
I believe this is a regression that happened some time between November 20 and December 4, because we have some code that was working around Nov 20 but started triggering this crash when we pulled in Dec 4 changes.
import _Differentiation
struct Reverser {
func apply(_ input: [Float]) -> [Float] {
var result = [Float]()
for i in 0..<withoutDerivative(at: input.count) {
result.append(input[withoutDerivative(at: input.count - 1 - i)])
}
return result
}
}
let g = gradient(at: [1.0, 2.0, 3.0]) { (x: [Float]) -> Float in
let reverser = Reverser()
return reverser.apply(x)[0]
}
Compile and run to get a segfault.
The backtrace is:
* thread #​1, name = 'main', stop reason = signal SIGSEGV: invalid address (fault address: 0x841f0e)
* frame #​0: 0x00007ffff7ddbc4d libswiftCore.so`swift_getAssociatedTypeWitnessSlowImpl(swift::MetadataRequest, swift::TargetWitnessTable<swift::InProcess>*, swift::TargetMetadata<swift::InProcess> const*, swift::TargetProtocolRequirement<swift::InProcess> const*, swift::TargetProtocolRequirement<swift::InProcess> const*) + 93
frame #​1: 0x00007ffff7dd9dde libswiftCore.so`swift_getAssociatedTypeWitness + 142
frame #​2: 0x0000555555559a2d main`AD__$s4main8ReverserV5applyySayxGAEF__pullback_src_0_wrt_0_16_Differentiation14DifferentiableRzl + 93
frame #​3: 0x0000555555557cc9 main`AD__$s4mainSfSaySfGcfU___pullback_src_0_wrt_0 + 121
frame #​4: 0x0000555555557954 main`reabstraction thunk helper from @escaping @callee_guaranteed (@unowned Swift.Float) -> (@owned Swift.Array<Swift.Float>.DifferentiableView) to @escaping @callee_guaranteed (@in_guaranteed Swift.Float) -> (@out Swift.Array<Swift.Float>.DifferentiableView) + 20
frame #​5: 0x000055555555a741 main`partial apply forwarder for reabstraction thunk helper from @escaping @callee_guaranteed (@unowned Swift.Float) -> (@owned Swift.Array<Swift.Float>.DifferentiableView) to @escaping @callee_guaranteed (@in_guaranteed Swift.Float) -> (@out Swift.Array<Swift.Float>.DifferentiableView) + 17
frame #​6: 0x00007ffff7f82503 libswift_Differentiation.so`_Differentiation.gradient<τ_0_0, τ_0_1 where τ_0_0: _Differentiation.Differentiable, τ_0_1: Swift.FloatingPoint, τ_0_1: _Differentiation.Differentiable, τ_0_1 == τ_0_1._Differentiation.Differentiable.TangentVector>(at: τ_0_0, in: @differentiable (τ_0_0) -> τ_0_1) -> τ_0_0.TangentVector + 131
frame #​7: 0x0000555555556fbd main`main + 525
frame #​8: 0x00007ffff75f4cca libc.so.6`__libc_start_main(main=(main`main), argc=1, argv=0x00007fffffffa118, init=<unavailable>, fini=<unavailable>, rtld_fini=<unavailable>, stack_end=0x00007fffffffa108) at libc-start.c:308:16
frame #​9: 0x0000555555556b5a main`_start + 42
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.