]> Cypherpunks repositories - gostls13.git/commit
runtime: size maps.Clone destination bucket array safely
authorKeith Randall <khr@golang.org>
Thu, 29 Aug 2024 22:08:33 +0000 (15:08 -0700)
committerKeith Randall <khr@golang.org>
Wed, 4 Sep 2024 16:06:05 +0000 (16:06 +0000)
commit1b4cf43e422031f94b55822447625772efd37ea8
tree9a3de88ff410816ce095ed9ce8b3c5cfaf6c5d0e
parenta4eba85fada2a312fc7df20e6f1e215eda8e6a4d
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 #69110

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