]> Cypherpunks repositories - gostls13.git/commit
runtime: check held locks with staticlockranking
authorMichael Pratt <mpratt@google.com>
Fri, 21 Aug 2020 15:49:56 +0000 (11:49 -0400)
committerMichael Pratt <mpratt@google.com>
Tue, 22 Sep 2020 15:13:57 +0000 (15:13 +0000)
commit53c9b9588a3a811bdf8d7ac2ff371bc2f95ed261
tree3ebd762fcf8f6189727976ae941fb85bcf3e20e8
parent0d83fe68a843df2113d0adaac9ac6299a1c2cdad
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>
src/runtime/lockrank_off.go
src/runtime/lockrank_on.go