x/tools/gopls: #53558
Labels
FrozenDueToAge
gopls
Issues related to the Go language server, gopls.
Tools
This label describes issues relating to any tools in the x/tools repository.
Milestone
gopls version
golang.org/x/tools/gopls v0.7.3 golang.org/x/tools/gopls@v0.7.3 h1:Lru57ht8vtDMouRskFC085VAjBAZRAISd/lwvwOOV0Q=
go env
GO111MODULE="on" GOARCH="amd64" GOBIN="" GOCACHE="/home/dusx/.cache/go-build" GOENV="/home/dusx/.config/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GOMODCACHE="/home/dusx/go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/home/dusx/go" GOPRIVATE="" GOPROXY="https://goproxy.cn,direct" GOROOT="/usr/local/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64" GOVCS="" GOVERSION="go1.17.6" GCCGO="gccgo" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/home/dusx/htap/go.mod" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1566950369=/tmp/go-build -gno-record-gcc-switches"
What did you do?
``
user sync.Pool to manage Objects
Through the test, we can know that if sync.Pool is written to the same object multiple times, like this: pool.Put(x) pool.Put(x), the buffer pool has no detection mechanism to ensure that the same object is not written multiple times. . Therefore, if the logic of using the cache is not rigorous, it will cause the same object to be written multiple times. If it is acquired multiple times, the same object will be used in different places, and the memory will be scrambled. So can you change the base class of the object to something like this:
type BaseSyncPoolObject struct { cached bool }
Check if cached is true when the object is put into the cache. If not true, put into cache and set to true. If true, do nothing.
``
The text was updated successfully, but these errors were encountered: