From 54c3c82269ca468f5d91fec2af13ee37b975495e Mon Sep 17 00:00:00 2001 From: qiulaidongfeng <2645477756@qq.com> Date: Sat, 4 May 2024 15:20:23 +0800 Subject: [PATCH] n Change-Id: Iad9d831d7b69427671d8327949a81b3c06794e11 --- src/runtime/chanbarrier_test.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/runtime/chanbarrier_test.go b/src/runtime/chanbarrier_test.go index 02140c4bb7..a85984d2d7 100644 --- a/src/runtime/chanbarrier_test.go +++ b/src/runtime/chanbarrier_test.go @@ -54,8 +54,6 @@ func TestChanSendBarrier(t *testing.T) { testChanSendBarrier(false) } -var globalMu sync.Mutex - func testChanSendBarrier(useSelect bool) { var wg sync.WaitGroup outer := 100 @@ -75,12 +73,15 @@ func testChanSendBarrier(useSelect bool) { if !ok { panic(1) } - garbage = make([]byte, 1<<10) + garbage = makeByte() } - globalMu.Lock() - global = garbage - globalMu.Unlock() + _ = garbage }() } wg.Wait() } + +//go:noinline +func makeByte() []byte { + return make([]byte, 1<<10) +}