diff options
| author | Youlin Feng <fengyoulin@live.com> | 2024-11-05 17:21:57 +0800 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2024-11-12 21:08:08 +0000 |
| commit | 1f8fa4941f632575468498bfac48fc1cbbf1a54f (patch) | |
| tree | 5cb0148c21ec9448d0c3c1267f1a92829f03b9c1 /src/cmd/compile/internal/reflectdata | |
| parent | 3efbc30f3d6a35cb5b0fc29d8bb3f43d59304771 (diff) | |
| download | go-1f8fa4941f632575468498bfac48fc1cbbf1a54f.tar.xz | |
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 <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/cmd/compile/internal/reflectdata')
| -rw-r--r-- | src/cmd/compile/internal/reflectdata/map_noswiss.go | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/cmd/compile/internal/reflectdata/map_noswiss.go b/src/cmd/compile/internal/reflectdata/map_noswiss.go index 07d0bb9049..a6fab4cbac 100644 --- a/src/cmd/compile/internal/reflectdata/map_noswiss.go +++ b/src/cmd/compile/internal/reflectdata/map_noswiss.go @@ -155,6 +155,7 @@ func OldMapType() *types.Type { // buckets unsafe.Pointer // oldbuckets unsafe.Pointer // nevacuate uintptr + // clearSeq uint64 // extra unsafe.Pointer // *mapextra // } // must match runtime/map.go:hmap. @@ -167,6 +168,7 @@ func OldMapType() *types.Type { makefield("buckets", types.Types[types.TUNSAFEPTR]), // Used in walk.go for OMAKEMAP. makefield("oldbuckets", types.Types[types.TUNSAFEPTR]), makefield("nevacuate", types.Types[types.TUINTPTR]), + makefield("clearSeq", types.Types[types.TUINT64]), makefield("extra", types.Types[types.TUNSAFEPTR]), } @@ -178,9 +180,9 @@ func OldMapType() *types.Type { hmap.SetUnderlying(types.NewStruct(fields)) types.CalcSize(hmap) - // The size of hmap should be 48 bytes on 64 bit - // and 28 bytes on 32 bit platforms. - if size := int64(8 + 5*types.PtrSize); hmap.Size() != size { + // The size of hmap should be 56 bytes on 64 bit + // and 36 bytes on 32 bit platforms. + if size := int64(2*8 + 5*types.PtrSize); hmap.Size() != size { base.Fatalf("hmap size not correct: got %d, want %d", hmap.Size(), size) } @@ -216,6 +218,7 @@ func OldMapIterType() *types.Type { // i uint8 // bucket uintptr // checkBucket uintptr + // clearSeq uint64 // } // must match runtime/map.go:hiter. fields := []*types.Field{ @@ -234,6 +237,7 @@ func OldMapIterType() *types.Type { makefield("i", types.Types[types.TUINT8]), makefield("bucket", types.Types[types.TUINTPTR]), makefield("checkBucket", types.Types[types.TUINTPTR]), + makefield("clearSeq", types.Types[types.TUINT64]), } // build iterator struct holding the above fields @@ -244,8 +248,8 @@ func OldMapIterType() *types.Type { hiter.SetUnderlying(types.NewStruct(fields)) types.CalcSize(hiter) - if hiter.Size() != int64(12*types.PtrSize) { - base.Fatalf("hash_iter size not correct %d %d", hiter.Size(), 12*types.PtrSize) + if hiter.Size() != int64(8+12*types.PtrSize) { + base.Fatalf("hash_iter size not correct %d %d", hiter.Size(), 8+12*types.PtrSize) } oldHiterType = hiter |
