aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid du Colombier <0intro@gmail.com>2017-10-12 22:59:16 +0200
committerDavid du Colombier <0intro@gmail.com>2017-10-17 15:15:07 +0000
commitd155b32f8de6a2a30c0567ec44f90ffab80ed6dc (patch)
tree080bd75200649a878c1634b05eb6e1febbb3464b
parent18508740b98db671608773c5f39bfa2718370f50 (diff)
downloadgo-d155b32f8de6a2a30c0567ec44f90ffab80ed6dc.tar.xz
runtime: disable use of template thread on Plan 9
CL 46033 added a "template thread" mechanism to allow creation of thread with a known-good state from a thread of unknown state. However, we are experiencing issues on Plan 9 with programs using the os/exec and net package. These package are relying on runtime.LockOSThread. Updates #22227. Change-Id: I85b71580a41df9fe8b24bd8623c064b6773288b0 Reviewed-on: https://go-review.googlesource.com/70231 Run-TryBot: David du Colombier <0intro@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
-rw-r--r--src/runtime/proc.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/runtime/proc.go b/src/runtime/proc.go
index b41f0c5ef8..4133b23584 100644
--- a/src/runtime/proc.go
+++ b/src/runtime/proc.go
@@ -1813,7 +1813,7 @@ func newm(fn func(), _p_ *p) {
mp := allocm(_p_, fn)
mp.nextp.set(_p_)
mp.sigmask = initSigmask
- if gp := getg(); gp != nil && gp.m != nil && (gp.m.lockedExt != 0 || gp.m.incgo) {
+ if gp := getg(); gp != nil && gp.m != nil && (gp.m.lockedExt != 0 || gp.m.incgo) && GOOS != "plan9" {
// We're on a locked M or a thread that may have been
// started by C. The kernel state of this thread may
// be strange (the user may have locked it for that
@@ -1821,6 +1821,8 @@ func newm(fn func(), _p_ *p) {
// thread. Instead, ask a known-good thread to create
// the thread for us.
//
+ // This is disabled on Plan 9. See golang.org/issue/22227.
+ //
// TODO: This may be unnecessary on Windows, which
// doesn't model thread creation off fork.
lock(&newmHandoff.lock)
@@ -3443,7 +3445,7 @@ func dolockOSThread() {
// A goroutine should call LockOSThread before calling OS services or
// non-Go library functions that depend on per-thread state.
func LockOSThread() {
- if atomic.Load(&newmHandoff.haveTemplateThread) == 0 {
+ if atomic.Load(&newmHandoff.haveTemplateThread) == 0 && GOOS != "plan9" {
// If we need to start a new thread from the locked
// thread, we need the template thread. Start it now
// while we're in a known-good state.