Skip to content

Commit b78e380

Browse files
neildgopherbot
authored andcommitted
runtime: define lock ranking between weak pointers and synctest
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>
1 parent 961818e commit b78e380

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

src/internal/synctest/synctest_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ import (
99
"internal/synctest"
1010
"iter"
1111
"reflect"
12+
"runtime"
1213
"slices"
1314
"strconv"
1415
"sync"
1516
"testing"
1617
"time"
18+
"weak"
1719
)
1820

1921
func TestNow(t *testing.T) {
@@ -625,6 +627,17 @@ func TestHappensBefore(t *testing.T) {
625627
}
626628
}
627629

630+
// https://go.dev/issue/73817
631+
func TestWeak(t *testing.T) {
632+
synctest.Run(func() {
633+
for range 100 {
634+
runtime.GC()
635+
b := make([]byte, 1024)
636+
weak.Make(&b)
637+
}
638+
})
639+
}
640+
628641
func wantPanic(t *testing.T, want string) {
629642
if e := recover(); e != nil {
630643
if got := fmt.Sprint(e); got != want {

src/runtime/lockrank.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/runtime/mklockrank.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,15 @@ NONE
9999
< reflectOffs;
100100
101101
# Synctest
102-
hchan, root, timers, timer, notifyList, reflectOffs < synctest;
102+
hchan,
103+
notifyList,
104+
reflectOffs,
105+
root,
106+
strongFromWeakQueue,
107+
sweepWaiters,
108+
timer,
109+
timers
110+
< synctest;
103111
104112
# User arena state
105113
NONE < userArenaState;

0 commit comments

Comments
 (0)