Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/gopls: #53558

Closed
dusx1981 opened this issue Jun 27, 2022 · 2 comments
Closed

x/tools/gopls: #53558

dusx1981 opened this issue Jun 27, 2022 · 2 comments
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

Comments

@dusx1981
Copy link

dusx1981 commented Jun 27, 2022

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.
``

@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Jun 27, 2022
@gopherbot gopherbot added this to the Unreleased milestone Jun 27, 2022
@ianlancetaylor
Copy link
Contributor

I'm sorry, that's not how the language works. There is no base class. And, if there were, we would not want to impose a cost on all values in order to let a few time avoid this problem in sync.Pool.

For questions or discussions, please see https://go.dev/wiki/Questions. Thanks.

@ianlancetaylor ianlancetaylor closed this as not planned Won't fix, can't repro, duplicate, stale Jun 27, 2022
@dusx1981
Copy link
Author

dusx1981 commented Jun 27, 2022 via email

@golang golang locked and limited conversation to collaborators Jun 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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.
Projects
None yet
Development

No branches or pull requests

3 participants