From 9059983fdb2cf64a08152d2aab648b6660b9631b Mon Sep 17 00:00:00 2001 From: Nicolas Lacasse Date: Fri, 13 Jul 2018 13:45:13 -0700 Subject: runsc: Fix map access race in boot.Loader.waitContainer. PiperOrigin-RevId: 204522004 Change-Id: I4819dc025f0a1df03ceaaba7951b1902d44562b3 --- runsc/boot/loader.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'runsc') diff --git a/runsc/boot/loader.go b/runsc/boot/loader.go index 7de0a84cc..706910d8a 100644 --- a/runsc/boot/loader.go +++ b/runsc/boot/loader.go @@ -499,10 +499,12 @@ func (l *Loader) waitContainer(cid string, waitStatus *uint32) error { // multiple clients to wait on the same container. l.mu.Lock() tgid, ok := l.containerRootTGIDs[cid] - l.mu.Unlock() if !ok { + defer l.mu.Unlock() return fmt.Errorf("can't find process for container %q in %v", cid, l.containerRootTGIDs) } + l.mu.Unlock() + // If the thread either has already exited or exits during waiting, // consider the container exited. defer func() { -- cgit v1.2.3