Fix potential use-after-free in the training ops.
The recent fix to a resource leak introduced a potential use-after-free, because it released a reference on a Var resource before returning a mutex* borrowed from that resource. The mutex* could therefore become garbage if the refcount concurrently dropped to zero (for example, if a concurrent `Session::Reset()` were issued). This change modifies the mutex accessing utilities to prolong the lifetime of the corresponding Var* beyond the lifetime of the returned mutex*. PiperOrigin-RevId: 214678937
Loading
Please sign in to comment