Skip to content

Commit

Permalink
runtime: convert local var stop,ready at TestDebugCallUnsafePoint to …
Browse files Browse the repository at this point in the history
…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>
  • Loading branch information
cuiweixie authored and mvdan committed Sep 5, 2022
1 parent 4e7e7ae commit 357b922
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/runtime/debug_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,16 +224,16 @@ 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()
defer runtime.UnlockOSThread()

*gpp = runtime.Getg()

for atomic.LoadUint32(stop) == 0 {
atomic.StoreUint32(ready, 1)
for !stop.Load() {
ready.Store(true)
}
}

Expand All @@ -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()
}

Expand Down

0 comments on commit 357b922

Please sign in to comment.