]> Cypherpunks repositories - gostls13.git/commit
runtime: fix race between unminit and Windows profile loop
authorAustin Clements <austin@google.com>
Fri, 17 Aug 2018 19:42:19 +0000 (15:42 -0400)
committerAustin Clements <austin@google.com>
Wed, 3 Oct 2018 20:56:26 +0000 (20:56 +0000)
commitc216c3aa9fe34cd81e9d4bcc28c64257064eddc9
treed242ff39b648f1339283e9b2d9e092f99b0851c1
parentf6fea0f31de094f43a4e7f659342de02585964ac
runtime: fix race between unminit and Windows profile loop

Currently, the Windows profile loop isn't robust against racing with
unminit. For example,

T1 is running profileloop1, T2 is another thread
T1: thread := atomic.Loaduintptr(&T2.thread)
T2: calls unminit, which does CloseHandle(T2.thread)
T1: attempts to suspends T2

In this case the SuspendThread will fail, but currently we ignore this
failure and forge ahead, which will cause further failures and
probably bad profile data.

Handle this race by defending against SuspendThread failing. If
SuspendThread succeeds, then we know the thread is no longer going
anywhere.

Change-Id: I4726553239b17f05ca07a0cf7df49631e0cb550d
Reviewed-on: https://go-review.googlesource.com/c/129685
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
src/runtime/os_windows.go