diff options
author | Michael Anthony Knyszek <mknyszek@google.com> | 2021-12-07 00:24:54 -0500 |
---|---|---|
committer | Michael Knyszek <mknyszek@google.com> | 2021-12-07 17:46:04 +0000 |
commit | 4c943abb95578da4bfd70d365814a130da8d5aa2 (patch) | |
tree | e0d4f858b936a0ebc4773b3aa197f14d2835c305 /misc | |
parent | dc65c489cc5a795a68d844ed7a45e5d16562401d (diff) | |
download | go-4c943abb95578da4bfd70d365814a130da8d5aa2.tar.gz go-4c943abb95578da4bfd70d365814a130da8d5aa2.zip |
runtime: fix comments on the behavior of SetGCPercent
Fixes for #49680, #49695, #45867, and #49370 all assumed that
SetGCPercent(-1) doesn't block until the GC's mark phase is done, but
it actually does. The cause of 3 of those 4 failures comes from the fact
that at the beginning of the sweep phase, the GC does try to preempt
every P once, and this may run concurrently with test code. In the
fourth case, the issue was likely that only *one* of the debug_test.go
tests was missing a call to SetGCPercent(-1). Just to be safe, leave a
TODO there for now to remove the extraneous runtime.GC calls, but leave
the calls in.
Updates #49680, #49695, #45867, and #49370.
Change-Id: Ibf4e64addfba18312526968bcf40f1f5d54eb3f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/369815
Reviewed-by: Austin Clements <austin@google.com>
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'misc')
-rw-r--r-- | misc/cgo/test/testdata/issue9400_linux.go | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/misc/cgo/test/testdata/issue9400_linux.go b/misc/cgo/test/testdata/issue9400_linux.go index 47f224dc4fb..051b9ab0bbe 100644 --- a/misc/cgo/test/testdata/issue9400_linux.go +++ b/misc/cgo/test/testdata/issue9400_linux.go @@ -50,7 +50,9 @@ func test9400(t *testing.T) { // Disable GC for the duration of the test. // This avoids a potential GC deadlock when spinning in uninterruptable ASM below #49695. defer debug.SetGCPercent(debug.SetGCPercent(-1)) - // And finish any pending GC after we pause, if any. + // SetGCPercent waits until the mark phase is over, but the runtime + // also preempts at the start of the sweep phase, so make sure that's + // done too. See #49695. runtime.GC() // Temporarily rewind the stack and trigger SIGSETXID |