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>
This commit is contained in:
cuiweixie 2022-09-02 10:18:51 +08:00 committed by Daniel Martí
parent 4e7e7ae140
commit 357b922517

View File

@ -224,7 +224,7 @@ func TestDebugCallGrowStack(t *testing.T) {
} }
//go:nosplit //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 // The nosplit causes this function to not contain safe-points
// except at calls. // except at calls.
runtime.LockOSThread() runtime.LockOSThread()
@ -232,8 +232,8 @@ func debugCallUnsafePointWorker(gpp **runtime.G, ready, stop *uint32) {
*gpp = runtime.Getg() *gpp = runtime.Getg()
for atomic.LoadUint32(stop) == 0 { for !stop.Load() {
atomic.StoreUint32(ready, 1) ready.Store(true)
} }
} }
@ -253,10 +253,10 @@ func TestDebugCallUnsafePoint(t *testing.T) {
// Test that the runtime refuses call injection at unsafe points. // Test that the runtime refuses call injection at unsafe points.
var g *runtime.G var g *runtime.G
var ready, stop uint32 var ready, stop atomic.Bool
defer atomic.StoreUint32(&stop, 1) defer stop.Store(true)
go debugCallUnsafePointWorker(&g, &ready, &stop) go debugCallUnsafePointWorker(&g, &ready, &stop)
for atomic.LoadUint32(&ready) == 0 { for !ready.Load() {
runtime.Gosched() runtime.Gosched()
} }