]> Cypherpunks repositories - gostls13.git/commit
reflect: fix race condition on funcTypes
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Mon, 3 Oct 2022 16:46:13 +0000 (23:46 +0700)
committerGopher Robot <gobot@golang.org>
Mon, 3 Oct 2022 20:06:58 +0000 (20:06 +0000)
commit6d8ec893039a39f495c8139012e47754e4518b70
treea9c17f9e8360d97fef7df2dfb91d78defff6d2ce
parent12daabb9156adb73fda453cae939ab4e3cb8e52f
reflect: fix race condition on funcTypes

CL 425314 made creating funcTypes using StructOf, and using a mutex to
protect read+write to funcTypes. However, after initializing funcTypes,
it is accessed in FuncOf without holding lock, causing a race.

Fixing it by returning the n-th Type directly from initFuncTypes, so the
accessing funcTypes will always be guarded by a mutex.

Fixes #56011

Change-Id: I1b50d1ae342943f16f368b8606f2614076dc90fb
Reviewed-on: https://go-review.googlesource.com/c/go/+/437997
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
src/reflect/all_test.go
src/reflect/type.go