From: cuiweixie Date: Fri, 2 Sep 2022 02:18:51 +0000 (+0800) Subject: runtime: convert local var stop,ready at TestDebugCallUnsafePoint to atomic type X-Git-Tag: go1.20rc1~1220 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=357b9225174fa227b47246e57f61a1bf66c1354c;p=gostls13.git 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 Run-TryBot: xie cui <523516579@qq.com> Reviewed-by: Heschi Kreinick TryBot-Result: Gopher Robot --- 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() }