diff options
| author | cuiweixie <cuiweixie@gmail.com> | 2022-09-02 10:18:51 +0800 |
|---|---|---|
| committer | Daniel Martà <mvdan@mvdan.cc> | 2022-09-05 08:07:47 +0000 |
| commit | 357b9225174fa227b47246e57f61a1bf66c1354c (patch) | |
| tree | f0a359c1f7ecada3968bc91dcd3101b6352aa93b /src/runtime | |
| parent | 4e7e7ae1406c70d9cc0809ec11105a55a60a0b70 (diff) | |
| download | go-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.go | 12 |
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() } |
