diff options
author | Michael Anthony Knyszek <mknyszek@google.com> | 2021-11-05 23:47:51 +0000 |
---|---|---|
committer | Michael Knyszek <mknyszek@google.com> | 2021-11-08 16:44:18 +0000 |
commit | 7bda349c1735fb6043b22d7a0e4542134baa6518 (patch) | |
tree | f230f7a211e40d01ced5ec21c47634286c96439f /src/runtime/crash_unix_test.go | |
parent | 7ee3f1427b079bb363689321b0565ba7b03de03e (diff) | |
download | go-git-7bda349c1735fb6043b22d7a0e4542134baa6518.tar.gz |
runtime: disable GC in TestPanicSystemstack's subprocess
TestPanicSystemstack spins up a subprocess that has 2 goroutines
deadlock on a runtime lock while on the system stack, with GOMAXPROCS=2.
Each goroutine is going to be running on a P, and then is going to wedge
itself up on that P.
If a GC is active and a worker starts executing (using a P), then it
could try to preempt a goroutine that is already blocked. It won't be
able to, so it'll just sit there forever trying to suspend it. At this
point there are no more Ps to execute the remaining goroutine that needs
to print something so the parent process can continue the test.
This change fixes this issue by disabling GCs in the child process. An
alternative fix could be to increase GOMAXPROCS in the child, but maybe
letting the GC be on (which assumes it'll always be able to *eventually*
suspend a G) is just asking for trouble.
Fixes #49388.
Change-Id: I405c9dad50e24e1e68f2c52a646538da15797fbe
Reviewed-on: https://go-review.googlesource.com/c/go/+/361897
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Diffstat (limited to 'src/runtime/crash_unix_test.go')
-rw-r--r-- | src/runtime/crash_unix_test.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/runtime/crash_unix_test.go b/src/runtime/crash_unix_test.go index 0d9d22aa49..0930a1b365 100644 --- a/src/runtime/crash_unix_test.go +++ b/src/runtime/crash_unix_test.go @@ -13,6 +13,7 @@ import ( "os" "os/exec" "runtime" + "runtime/debug" "strings" "sync" "syscall" @@ -211,6 +212,11 @@ func TestPanicSystemstack(t *testing.T) { func init() { if len(os.Args) >= 2 && os.Args[1] == "testPanicSystemstackInternal" { + // Complete any in-flight GCs and disable future ones. We're going to + // block goroutines on runtime locks, which aren't ever preemptible for the + // GC to scan them. + runtime.GC() + debug.SetGCPercent(-1) // Get two threads running on the system stack with // something recognizable in the stack trace. runtime.GOMAXPROCS(2) |