]> Cypherpunks repositories - gostls13.git/commit
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)
committerMichael Knyszek <mknyszek@google.com>
Wed, 19 Dec 2018 19:47:56 +0000 (19:47 +0000)
commitd0f8a7517ab0b33c8e3dd49294800dd6144e4cee
tree9bf7f5ed31e0197d84480fe0ef9b1e52561f891b
parent6fcab648af59faab639f3453354a7a14c888e75c
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 OSs 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 #28979.

Change-Id: I7d3d71dd65bcb873e9758086d2cbcb9a06429b0f
Reviewed-on: https://go-review.googlesource.com/c/153078
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Austin Clements <austin@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]