]> Cypherpunks.ru repositories - gostls13.git/commit
runtime: terminate locked OS thread if its goroutine exits
authorAustin Clements <austin@google.com>
Fri, 16 Jun 2017 20:21:12 +0000 (16:21 -0400)
committerAustin Clements <austin@google.com>
Wed, 11 Oct 2017 17:47:21 +0000 (17:47 +0000)
commit4f34a5291317fe959074fb40b85d9be242b8a2fc
tree366434d6858a14b2b92bdfa04100390a0eafd1ac
parenteff2b2620db005cb58c266c0f25309d6f466cb25
runtime: terminate locked OS thread if its goroutine exits

runtime.LockOSThread is sometimes used when the caller intends to put
the OS thread into an unusual state. In this case, we never want to
return this thread to the runtime thread pool. However, currently
exiting the goroutine implicitly unlocks its OS thread.

Fix this by terminating the locked OS thread when its goroutine exits,
rather than simply returning it to the pool.

Fixes #20395.

Change-Id: I3dcec63b200957709965f7240dc216fa84b62ad9
Reviewed-on: https://go-review.googlesource.com/46038
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/runtime/crash_cgo_test.go
src/runtime/crash_test.go
src/runtime/proc.go
src/runtime/proc_test.go
src/runtime/testdata/testprog/gettid.go [new file with mode: 0644]
src/runtime/testdata/testprog/gettid_none.go [new file with mode: 0644]
src/runtime/testdata/testprog/lockosthread.go [new file with mode: 0644]
src/runtime/testdata/testprogcgo/lockosthread.c [new file with mode: 0644]
src/runtime/testdata/testprogcgo/lockosthread.go [new file with mode: 0644]