Skip to content

Commit d155b32

Browse files
committed
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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Austin Clements <[email protected]>
1 parent 1850874 commit d155b32

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/runtime/proc.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -1813,14 +1813,16 @@ func newm(fn func(), _p_ *p) {
18131813
mp := allocm(_p_, fn)
18141814
mp.nextp.set(_p_)
18151815
mp.sigmask = initSigmask
1816-
if gp := getg(); gp != nil && gp.m != nil && (gp.m.lockedExt != 0 || gp.m.incgo) {
1816+
if gp := getg(); gp != nil && gp.m != nil && (gp.m.lockedExt != 0 || gp.m.incgo) && GOOS != "plan9" {
18171817
// We're on a locked M or a thread that may have been
18181818
// started by C. The kernel state of this thread may
18191819
// be strange (the user may have locked it for that
18201820
// purpose). We don't want to clone that into another
18211821
// thread. Instead, ask a known-good thread to create
18221822
// the thread for us.
18231823
//
1824+
// This is disabled on Plan 9. See golang.org/issue/22227.
1825+
//
18241826
// TODO: This may be unnecessary on Windows, which
18251827
// doesn't model thread creation off fork.
18261828
lock(&newmHandoff.lock)
@@ -3443,7 +3445,7 @@ func dolockOSThread() {
34433445
// A goroutine should call LockOSThread before calling OS services or
34443446
// non-Go library functions that depend on per-thread state.
34453447
func LockOSThread() {
3446-
if atomic.Load(&newmHandoff.haveTemplateThread) == 0 {
3448+
if atomic.Load(&newmHandoff.haveTemplateThread) == 0 && GOOS != "plan9" {
34473449
// If we need to start a new thread from the locked
34483450
// thread, we need the template thread. Start it now
34493451
// while we're in a known-good state.

0 commit comments

Comments
 (0)