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

go/src /sync/: Release lock behavior varies across different operating systems. #70796

Closed
Sudingyi opened this issue Dec 12, 2024 · 3 comments
Closed

Comments

@Sudingyi
Copy link

Go version

go version go1.21.4 linux/arm64

Output of go env in your module/workspace:

GO111MODULE='on'
GOARCH='arm64'
GOBIN=''
GOCACHE='/home/parallels/.cache/go-build'
GOENV='/home/parallels/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/parallels/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/parallels/go'
GOPRIVATE=''
GOPROXY='https://goproxy.io,direct'
GOROOT='/opt/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/go/pkg/tool/linux_arm64'
GOVCS=''
GOVERSION='go1.21.4'
GCCGO='gccgo'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/parallels/zhangyaru/GBproxy/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build4139936400=/tmp/go-build -gno-record-gcc-switches'

What did you do?

defer b.lock.Unlock()
Put the current statement inside a for loop.like
for ...{ .... if if b.lock.TryLock() { defer b.lock.Unlock() ... } }

What did you see happen?

Put the current statement inside a for loop so that the lock is released without exiting the function.
The same statement behaves as not releasing the lock on both Windows and other Linux.

What did you expect to see?

Does not release the lock.

@seankhliao
Copy link
Member

seankhliao commented Dec 12, 2024

it seems to me you are most likely misusing locks.

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Dec 12, 2024
@Sudingyi
Copy link
Author

Okay.However, the same code behaves inconsistently across two different systems.

@ianlancetaylor
Copy link
Member

This seems like a good question to raise on a forum. See https://go.dev/wiki/Questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants