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

sync: RWMutex should panic on RUnlock of non-RLocked lock #7877

Closed
calmh opened this issue Apr 27, 2014 · 1 comment
Closed

sync: RWMutex should panic on RUnlock of non-RLocked lock #7877

calmh opened this issue Apr 27, 2014 · 1 comment

Comments

@calmh
Copy link
Contributor

calmh commented Apr 27, 2014

It would be nice if RUnlock() panicked if called when the mutex is not read locked,
similar to how Unlock() panics when the mutex is not write locked. As it is, bugs
related to mismatched rlocking are harder to find. The documentation states that
"It is a run-time error if rw is not locked for reading on entry to RUnlock."
which I interpret as we intended this to panic.

Go v1.2.1

The program:

http://play.golang.org/p/GmAqwC5WJo

Now prints:

Read locked
Also, write locked

While I would expect it to panic on line 10.
@dvyukov
Copy link
Member

dvyukov commented Apr 27, 2014

Comment 1:

Status changed to Duplicate.

Merged into issue #7858.

@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
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