]> Cypherpunks repositories - gostls13.git/commit
runtime: ensure thread handle is valid in profileloop1
authorAustin Clements <austin@google.com>
Tue, 19 Nov 2019 01:21:38 +0000 (20:21 -0500)
committerAustin Clements <austin@google.com>
Wed, 20 Nov 2019 17:13:48 +0000 (17:13 +0000)
commit6fd467ee29226bf4b875921b7cb3b692c9db52ef
treeb808cbf92d357cc258fafc66a3954c44bdc34008
parent91bb1d734ecb44f687f3549ace10ee8f70e977a8
runtime: ensure thread handle is valid in profileloop1

On Windows, there is currently a race between unminit closing the
thread's handle and profileloop1 suspending the thread using its
handle. If another handle reuses the same handle value, this can lead
to unpredictable results.

To fix this, we protect the thread handle with a lock and duplicate it
under this lock in profileloop1 before using it.

This is going to become a much bigger problem with non-cooperative
preemption (#10958, #24543), which uses the same basic mechanism as
profileloop1.

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