From 1f8fa4941f632575468498bfac48fc1cbbf1a54f Mon Sep 17 00:00:00 2001 From: Youlin Feng Date: Tue, 5 Nov 2024 17:21:57 +0800 Subject: runtime: fix iterator returns map entries after clear (pre-swissmap) Fixes #70189 Fixes #59411 Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest-noswissmap Change-Id: I4ef7ecd7e996330189309cb2a658cf34bf9e1119 Reviewed-on: https://go-review.googlesource.com/c/go/+/625275 Reviewed-by: Keith Randall Reviewed-by: Keith Randall Auto-Submit: Keith Randall Reviewed-by: Michael Pratt LUCI-TryBot-Result: Go LUCI --- src/runtime/map_noswiss.go | 28 ++++++++-------------------- src/runtime/map_noswiss_test.go | 4 ++-- 2 files changed, 10 insertions(+), 22 deletions(-) (limited to 'src/runtime') diff --git a/src/runtime/map_noswiss.go b/src/runtime/map_noswiss.go index d7b8a5fe11..327f0c81e8 100644 --- a/src/runtime/map_noswiss.go +++ b/src/runtime/map_noswiss.go @@ -123,6 +123,7 @@ type hmap struct { buckets unsafe.Pointer // array of 2^B Buckets. may be nil if count==0. oldbuckets unsafe.Pointer // previous bucket array of half the size, non-nil only when growing nevacuate uintptr // progress counter for evacuation (buckets less than this have been evacuated) + clearSeq uint64 extra *mapextra // optional fields } @@ -176,6 +177,7 @@ type hiter struct { i uint8 bucket uintptr checkBucket uintptr + clearSeq uint64 } // bucketShift returns 1<