]> Cypherpunks repositories - gostls13.git/commit
sync: throw, not panic, for unlock of unlocked mutex
authorRuss Cox <rsc@golang.org>
Tue, 18 Oct 2016 14:26:07 +0000 (10:26 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 19 Oct 2016 17:46:27 +0000 (17:46 +0000)
commit40d81cf061d8a2a277d70446f582a984c1701ff3
tree42523f5eeede8a134a4d98be034fd37f9f592750
parentd2315fdc11ebdf5c0ae94f33cb01ffaab82c00b6
sync: throw, not panic, for unlock of unlocked mutex

The panic leaves the lock in an unusable state.
Trying to panic with a usable state makes the lock significantly
less efficient and scalable (see early CL patch sets and discussion).

Instead, use runtime.throw, which will crash the program directly.

In general throw is reserved for when the runtime detects truly
serious, unrecoverable problems. This problem is certainly serious,
and, without a significant performance hit, is unrecoverable.

Fixes #13879.

Change-Id: I41920d9e2317270c6f909957d195bd8b68177f8d
Reviewed-on: https://go-review.googlesource.com/31359
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/runtime/panic.go
src/sync/mutex.go
src/sync/mutex_test.go
src/sync/rwmutex.go
src/sync/rwmutex_test.go