mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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>
This commit is contained in:
parent
961818e013
commit
b78e38065e
3 changed files with 23 additions and 2 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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},
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue