diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-01-15 13:01:37 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-01-18 18:16:12 +0000 |
commit | dbab07983596c705d2ef12806e0f9d630063e571 (patch) | |
tree | eeaaf7725034ade0ca0978928b39a20c7a192439 /src/runtime/proc.go | |
parent | 5a8fbb0d2d339fa87a02c0794f5a92c1ce121631 (diff) | |
download | go-dbab07983596c705d2ef12806e0f9d630063e571.tar.gz go-dbab07983596c705d2ef12806e0f9d630063e571.zip |
runtime: free Windows event handles after last lock is dropped
Calls to lock may need to use global members of mOS that also need to be
cleaned up before the thread exits. Before this commit, these resources
would leak. Moving them to be cleaned up in unminit, however, would race
with gstack on unix. So this creates a new helper, mdestroy, to release
resources that must be destroyed only after locks are no longer
required. We also move highResTimer lifetime to the same semantics,
since it doesn't help to constantly acquire and release the timer object
during dropm.
Updates #43720.
Change-Id: Ib3f598f3fda1b2bbcb608099616fa4f85bc1c289
Reviewed-on: https://go-review.googlesource.com/c/go/+/284137
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Trust: Alex Brainman <alex.brainman@gmail.com>
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/runtime/proc.go')
-rw-r--r-- | src/runtime/proc.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/runtime/proc.go b/src/runtime/proc.go index 5a942a6831..b776f88936 100644 --- a/src/runtime/proc.go +++ b/src/runtime/proc.go @@ -1407,6 +1407,10 @@ found: } } + // Destroy all allocated resources. After this is called, we may no + // longer take any locks. + mdestroy(m) + if osStack { // Return from mstart and let the system thread // library free the g0 stack and terminate the thread. |