aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/lockrank_off.go
diff options
context:
space:
mode:
authorMichael Pratt <mpratt@google.com>2020-08-21 11:49:56 -0400
committerMichael Pratt <mpratt@google.com>2020-09-22 15:13:57 +0000
commit53c9b9588a3a811bdf8d7ac2ff371bc2f95ed261 (patch)
tree3ebd762fcf8f6189727976ae941fb85bcf3e20e8 /src/runtime/lockrank_off.go
parent0d83fe68a843df2113d0adaac9ac6299a1c2cdad (diff)
downloadgo-53c9b9588a3a811bdf8d7ac2ff371bc2f95ed261.tar.gz
go-53c9b9588a3a811bdf8d7ac2ff371bc2f95ed261.zip
runtime: check held locks with staticlockranking
When lock ranking is enabled, we can now assert that lock preconditions are met by checking that the caller holds required locks on function entry. This change adds the infrastructure to add assertions. Actual assertions will be added for various locks in subsequent changes. Some functions are protected by locks that are not directly accessible in the function. In that case, we can use assertRankHeld to check that any lock with the rank is held. This is less precise, but it avoids requiring passing the lock into the functions. Updates #40677 Change-Id: I843c6874867f975e90a063f087b6e2ffc147877b Reviewed-on: https://go-review.googlesource.com/c/go/+/245484 Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Michael Pratt <mpratt@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
Diffstat (limited to 'src/runtime/lockrank_off.go')
-rw-r--r--src/runtime/lockrank_off.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/runtime/lockrank_off.go b/src/runtime/lockrank_off.go
index 32378a9627..c04b61edc7 100644
--- a/src/runtime/lockrank_off.go
+++ b/src/runtime/lockrank_off.go
@@ -44,3 +44,11 @@ func releaseLockRank(rank lockRank) {
//go:nosplit
func lockWithRankMayAcquire(l *mutex, rank lockRank) {
}
+
+//go:nosplit
+func assertLockHeld(l *mutex) {
+}
+
+//go:nosplit
+func assertRankHeld(r lockRank) {
+}