]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: fix deadlock in (*Named).load
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Sun, 5 Sep 2021 13:50:54 +0000 (20:50 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Tue, 7 Sep 2021 17:38:14 +0000 (17:38 +0000)
commit2a4845257fea627da8b30444a498576ea90b5401
tree91092c768eb8ddc68aba870fe14aa03fb990395c
parentbca8c6ffa2dd19d49685531650ea6553262837e3
cmd/compile: fix deadlock in (*Named).load

For lazy import resolution, there's reentrancy issue with (*Named).load
method, when "t.resolve(t)" can lead us to the same named type, thus
(*Named).load is called recursively, causing the deadlock.

The main problem is that when instantinate a type, we calculate the type
hashing, including TParams. Calling t.TParams().Len() triggers the
reentrancy call to "(*Named).load".

To fix this, just not checking TParams().Len() if we are hashing.

Updates #48185

Change-Id: Ie34842d7b10fad5d11fbcf75bb1c64a89deac6b8
Reviewed-on: https://go-review.googlesource.com/c/go/+/347534
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
src/cmd/compile/internal/types2/typestring.go
test/typeparam/issue48185a.dir/p.go [new file with mode: 0644]
test/typeparam/issue48185a.dir/p_test.go [new file with mode: 0644]
test/typeparam/issue48185a.go [new file with mode: 0644]