]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: define lock ranking between weak pointers and synctest
authorDamien Neil <dneil@google.com>
Wed, 21 May 2025 20:02:59 +0000 (13:02 -0700)
committerGopher Robot <gobot@golang.org>
Tue, 27 May 2025 21:47:09 +0000 (14:47 -0700)
Fixes #73817

Change-Id: I0101bdc797237b4c7eb58b414c71b009b0b44447
Reviewed-on: https://go-review.googlesource.com/c/go/+/675176
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Damien Neil <dneil@google.com>

src/internal/synctest/synctest_test.go
src/runtime/lockrank.go
src/runtime/mklockrank.go

index e46040e0488b705ac086befb941561398d004325..7f71df1710056a8e7887ae6392bca2a80fc31a0e 100644 (file)
@@ -9,11 +9,13 @@ import (
        "internal/synctest"
        "iter"
        "reflect"
+       "runtime"
        "slices"
        "strconv"
        "sync"
        "testing"
        "time"
+       "weak"
 )
 
 func TestNow(t *testing.T) {
@@ -625,6 +627,17 @@ func TestHappensBefore(t *testing.T) {
        }
 }
 
+// https://go.dev/issue/73817
+func TestWeak(t *testing.T) {
+       synctest.Run(func() {
+               for range 100 {
+                       runtime.GC()
+                       b := make([]byte, 1024)
+                       weak.Make(&b)
+               }
+       })
+}
+
 func wantPanic(t *testing.T, want string) {
        if e := recover(); e != nil {
                if got := fmt.Sprint(e); got != want {
index 456f2b75e6aa87b76cac0026008db300229c5583..7f32e6397bf7e1b967d866dd4d2f270c7aea0cd1 100644 (file)
@@ -204,7 +204,7 @@ var lockPartialOrder [][]lockRank = [][]lockRank{
        lockRankRoot:                {},
        lockRankItab:                {},
        lockRankReflectOffs:         {lockRankItab},
-       lockRankSynctest:            {lockRankSysmon, lockRankScavenge, lockRankSweep, lockRankTestR, lockRankTimerSend, lockRankPollDesc, lockRankWakeableSleep, lockRankHchan, lockRankNotifyList, lockRankTimers, lockRankTimer, lockRankRoot, lockRankItab, lockRankReflectOffs},
+       lockRankSynctest:            {lockRankSysmon, lockRankScavenge, lockRankSweepWaiters, lockRankStrongFromWeakQueue, lockRankSweep, lockRankTestR, lockRankTimerSend, lockRankPollDesc, lockRankWakeableSleep, lockRankHchan, lockRankNotifyList, lockRankTimers, lockRankTimer, lockRankRoot, lockRankItab, lockRankReflectOffs},
        lockRankUserArenaState:      {},
        lockRankTraceBuf:            {lockRankSysmon, lockRankScavenge},
        lockRankTraceStrings:        {lockRankSysmon, lockRankScavenge, lockRankTraceBuf},
index 6cccece9b53a0702b13089e710b8e2f9862f75c6..2e3375331af52860ed7c4b11eac4f04848a5037e 100644 (file)
@@ -99,7 +99,15 @@ NONE
 < reflectOffs;
 
 # Synctest
-hchan, root, timers, timer, notifyList, reflectOffs < synctest;
+hchan,
+  notifyList,
+  reflectOffs,
+  root,
+  strongFromWeakQueue,
+  sweepWaiters,
+  timer,
+  timers
+< synctest;
 
 # User arena state
 NONE < userArenaState;