diff options
author | Joshua M. Clulow <josh@sysmgr.org> | 2020-11-29 17:18:51 -0800 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2020-11-30 03:18:36 +0000 |
commit | e5da18df52e3f81534d7cdb6920cf993b5f079d2 (patch) | |
tree | 25dedf3d7372a2297fdf4dfdf7fac2dbf838a5c5 | |
parent | 4ce0a7cea6805277c3bfecbaab2170e5c2543cba (diff) | |
download | go-e5da18df52e3f81534d7cdb6920cf993b5f079d2.tar.gz go-e5da18df52e3f81534d7cdb6920cf993b5f079d2.zip |
os/exec: constrain thread usage in leaked descriptor test on illumos
On illumos systems, libc can under some conditions make use of files
from /proc. In the case of this test, the creation of new threads was
(in the target thread) causing libc to open and close
"/proc/self/lwp/5/lwpname" to set the thread name, which raced with the
leaking descriptor check (see detailed analysis in #42431).
This change requests that the Go runtime use less threads in the child
process used to check for leaked descriptors, without just disabling the
test. After a thousand repeated trials, the test no longer fails on
illumos.
Fixes #42431.
Change-Id: Iefda26134fc91f7cb205754676e9845d9b7205cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/273966
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
-rw-r--r-- | src/os/exec/exec_test.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/os/exec/exec_test.go b/src/os/exec/exec_test.go index cd3d759ebc..fc49b8a332 100644 --- a/src/os/exec/exec_test.go +++ b/src/os/exec/exec_test.go @@ -691,6 +691,18 @@ func TestExtraFiles(t *testing.T) { c.Stdout = &stdout c.Stderr = &stderr c.ExtraFiles = []*os.File{tf} + if runtime.GOOS == "illumos" { + // Some facilities in illumos are implemented via access + // to /proc by libc; such accesses can briefly occupy a + // low-numbered fd. If this occurs concurrently with the + // test that checks for leaked descriptors, the check can + // become confused and report a spurious leaked descriptor. + // (See issue #42431 for more detailed analysis.) + // + // Attempt to constrain the use of additional threads in the + // child process to make this test less flaky: + c.Env = append(os.Environ(), "GOMAXPROCS=1") + } err = c.Run() if err != nil { t.Fatalf("Run: %v\n--- stdout:\n%s--- stderr:\n%s", err, stdout.Bytes(), stderr.Bytes()) |