]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.23] 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:57 +0000 (14:32 +0000)
commita886959aa2fb1115096a937d3d8a2e921388752f
tree04e7ba1979d2efefb1339a05043f9a18e198929a
parent80ff7cd35ad35e6518b539f4eb2517928c2f8945
[release-branch.go1.23] 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 #69156

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