]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.22] runtime: size maps.Clone destination bucket array safely
authorKeith Randall <khr@golang.org>
Thu, 29 Aug 2024 22:08:33 +0000 (15:08 -0700)
committerGopher Robot <gobot@golang.org>
Fri, 6 Sep 2024 14:32:54 +0000 (14:32 +0000)
commit6fab4b9a9eccbfdae14bdeb45cd3ae625ae2081e
tree2d555d8c7e7c3c9621c20cdb7a7d6058efd91c18
parent71655f14cecefb16cc8969e43a6a9631f74d72ee
[release-branch.go1.22] runtime: size maps.Clone destination bucket array safely

In rare situations, like during same-sized grows, the source map for
maps.Clone may be overloaded (has more than 6.5 entries per
bucket). This causes the runtime to allocate a larger bucket array for
the destination map than for the source map. The maps.Clone code
walks off the end of the source array if it is smaller than the
destination array.

This is a pretty simple fix, ensuring that the destination bucket
array is never longer than the source bucket array. Maybe a better fix
is to make the Clone code handle shorter source arrays correctly, but
this fix is deliberately simple to reduce the risk of backporting this
fix.

Fixes #69155

Change-Id: I824c93d1db690999f25a3c43b2816fc28ace7509
Reviewed-on: https://go-review.googlesource.com/c/go/+/610238
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
src/runtime/map.go
test/fixedbugs/issue69110.go [new file with mode: 0644]