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/sync: semaphore/semaphore.go:132 Defect type: GUARDED_BY_VIOLATION #46231

Closed
opohorel opened this issue May 18, 2021 · 1 comment
Closed

x/sync: semaphore/semaphore.go:132 Defect type: GUARDED_BY_VIOLATION #46231

opohorel opened this issue May 18, 2021 · 1 comment

Comments

@opohorel
Copy link

Static analyzer has detected this issue in x/sync/semaphore/semaphore.go:132.
As I'm not familiar with golang and x/sync, this could be a false positive.

4. git-lfs-2.13.3/_build/src/github.com/git-lfs/git-lfs/vendor/golang.org/x/sync/semaphore/semaphore.go:132: missing_lock: Accessing "s.cur" without holding lock "semaphore.Weighted.mu". Elsewhere, "golang.org/x/sync/semaphore.Weighted.cur" is accessed with "Weighted.mu" held 3 out of 4 times.
5. git-lfs-2.13.3/_build/src/github.com/git-lfs/git-lfs/vendor/golang.org/x/sync/semaphore/semaphore.go:41: example_lock: Example 1: Locking "semaphore.Weighted.mu".
6. git-lfs-2.13.3/_build/src/github.com/git-lfs/git-lfs/vendor/golang.org/x/sync/semaphore/semaphore.go:43: example_access: Example 1 (cont.): "semaphore.Weighted.cur" is accessed with lock "semaphore.Weighted.mu" held.
7. git-lfs-2.13.3/_build/src/github.com/git-lfs/git-lfs/vendor/golang.org/x/sync/semaphore/semaphore.go:99: example_lock: Example 2: Locking "semaphore.Weighted.mu".
8. git-lfs-2.13.3/_build/src/github.com/git-lfs/git-lfs/vendor/golang.org/x/sync/semaphore/semaphore.go:100: example_access: Example 2 (cont.): "semaphore.Weighted.cur" is accessed with lock "semaphore.Weighted.mu" held.
9. git-lfs-2.13.3/_build/src/github.com/git-lfs/git-lfs/vendor/golang.org/x/sync/semaphore/semaphore.go:88: example_lock: Example 3: Locking "semaphore.Weighted.mu".
10. git-lfs-2.13.3/_build/src/github.com/git-lfs/git-lfs/vendor/golang.org/x/sync/semaphore/semaphore.go:91: example_access: Example 3 (cont.): "semaphore.Weighted.cur" is accessed with lock "semaphore.Weighted.mu" held.
#   130|   		}
#   131|   
#   132|-> 		s.cur += w.n
#   133|   		s.waiters.Remove(next)
#   134|   		close(w.ready)
@bcmills
Copy link
Contributor

bcmills commented May 18, 2021

This is a false positive. (*Weighted).notifyWaiters is only called with mu already locked.

@bcmills bcmills closed this as completed May 18, 2021
@golang golang locked and limited conversation to collaborators May 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants