Skip to content

fix(semaphore): panic on Unlock without a matching Lock - #19

Closed
MrBeldum wants to merge 1 commit into
go-pkgz:masterfrom
MrBeldum:fix/semaphore-unlock-unlocked
Closed

MrBeldum wants to merge 1 commit into
go-pkgz:masterfrom
MrBeldum:fix/semaphore-unlock-unlocked

Conversation

@MrBeldum

@MrBeldum MrBeldum commented Oct 5, 2026

Copy link
Copy Markdown

Summary

  • Semaphore.Unlock previously blocked forever when nothing was held (receive on an empty capacity channel).
  • Panic with a clear message instead, matching sync.Mutex misuse behavior.
  • Add coverage for unlock-without-lock and double-unlock.

Test plan

  • go test ./...

An Unlock on an empty semaphore previously blocked forever on a receive
from the capacity channel. Match sync.Mutex and panic instead so misuse
is obvious rather than hanging the caller.
@MrBeldum
MrBeldum requested a review from umputun as a code owner October 5, 2026 20:53
@umputun umputun closed this Oct 6, 2026
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

Successfully merging this pull request may close these issues.

2 participants