]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.11] runtime: don't clear lockedExt on locked M when G exits
authorMichael Anthony Knyszek <mknyszek@google.com>
Fri, 7 Dec 2018 00:07:43 +0000 (00:07 +0000)
committerIan Lance Taylor <iant@golang.org>
Wed, 19 Dec 2018 22:59:49 +0000 (22:59 +0000)
commitf500f13d72de3ca3201ec2678a7f88524353bede
tree9182577b0af8134af79962428d5fc3602f16c2fc
parenta171e155000d1f40a6e467e56b4af3a237613c1f
[release-branch.go1.11] runtime: don't clear lockedExt on locked M when G exits

When a locked M has its G exit without calling UnlockOSThread, then
lockedExt on it was getting cleared. Unfortunately, this meant that
during P handoff, if a new M was started, it might get forked (on
most OSes besides Windows) from the locked M, which could have kernel
state attached to it.

To solve this, just don't clear lockedExt. At the point where the
locked M has its G exit, it will also exit in accordance with the
LockOSThread API. So, we can safely assume that it's lockedExt state
will no longer be used. For the case of the main thread where it just
gets wedged instead of exiting, it's probably better for it to keep
the locked marker since it more accurately represents its state.

Fixed #28986.

Change-Id: I7d3d71dd65bcb873e9758086d2cbcb9a06429b0f
Reviewed-on: https://go-review.googlesource.com/c/155117
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
src/runtime/proc.go
src/runtime/proc_test.go
src/runtime/testdata/testprog/gettid.go [deleted file]
src/runtime/testdata/testprog/lockosthread.go
src/runtime/testdata/testprog/syscalls.go [new file with mode: 0644]
src/runtime/testdata/testprog/syscalls_none.go [moved from src/runtime/testdata/testprog/gettid_none.go with 68% similarity]