aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorcuiweixie <cuiweixie@gmail.com>2022-09-02 10:18:51 +0800
committerDaniel Martí <mvdan@mvdan.cc>2022-09-05 08:07:47 +0000
commit357b9225174fa227b47246e57f61a1bf66c1354c (patch)
treef0a359c1f7ecada3968bc91dcd3101b6352aa93b /src/runtime
parent4e7e7ae1406c70d9cc0809ec11105a55a60a0b70 (diff)
downloadgo-357b9225174fa227b47246e57f61a1bf66c1354c.tar.xz
runtime: convert local var stop,ready at TestDebugCallUnsafePoint to atomic type
For #53821 Change-Id: Id972d4ccadc72de69dea46f8be146c9843d1d095 Reviewed-on: https://go-review.googlesource.com/c/go/+/427135 Reviewed-by: Michael Knyszek <mknyszek@google.com> Run-TryBot: xie cui <523516579@qq.com> Reviewed-by: Heschi Kreinick <heschi@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/debug_test.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/runtime/debug_test.go b/src/runtime/debug_test.go
index 75fe07ec2a..b231be344c 100644
--- a/src/runtime/debug_test.go
+++ b/src/runtime/debug_test.go
@@ -224,7 +224,7 @@ func TestDebugCallGrowStack(t *testing.T) {
}
//go:nosplit
-func debugCallUnsafePointWorker(gpp **runtime.G, ready, stop *uint32) {
+func debugCallUnsafePointWorker(gpp **runtime.G, ready, stop *atomic.Bool) {
// The nosplit causes this function to not contain safe-points
// except at calls.
runtime.LockOSThread()
@@ -232,8 +232,8 @@ func debugCallUnsafePointWorker(gpp **runtime.G, ready, stop *uint32) {
*gpp = runtime.Getg()
- for atomic.LoadUint32(stop) == 0 {
- atomic.StoreUint32(ready, 1)
+ for !stop.Load() {
+ ready.Store(true)
}
}
@@ -253,10 +253,10 @@ func TestDebugCallUnsafePoint(t *testing.T) {
// Test that the runtime refuses call injection at unsafe points.
var g *runtime.G
- var ready, stop uint32
- defer atomic.StoreUint32(&stop, 1)
+ var ready, stop atomic.Bool
+ defer stop.Store(true)
go debugCallUnsafePointWorker(&g, &ready, &stop)
- for atomic.LoadUint32(&ready) == 0 {
+ for !ready.Load() {
runtime.Gosched()
}