Clarify comment about copying Task.image in Task.Clone().

PiperOrigin-RevId: 510829046
This commit is contained in:
Nicolas Lacasse
2023-02-19 10:43:46 -08:00
committed by gVisor bot
parent c020e2de83
commit 028cf757bb
+3 -2
View File
@@ -136,8 +136,9 @@ func (t *Task) Clone(args *linux.CloneArgs) (ThreadID, *SyscallControl, error) {
})
}
// We must hold t.mu to access t.image, but want to avoid holding the lock
// during Fork() call, so we make a copy.
// We must hold t.mu to access t.image, but we can't hold it during Fork(),
// since TaskImage.Fork()=>mm.Fork() takes mm.addressSpaceMu, which is ordered
// above Task.mu. So we copy t.image with t.mu held and call Fork() on the copy.
t.mu.Lock()
curImage := t.image
t.mu.Unlock()