Documentation
¶
Overview ¶
Package lockorder is a lock-acquisition-order checker for instrumented test builds.
The end-to-end journey harness (test/journeys) rewrites every sync.Mutex and sync.RWMutex of the PiG module into this package's types with a build overlay, so a binary built for a journey records which locks a goroutine holds when it takes another. A cycle in that order graph (lock A taken while holding B on one path, B while holding A on another) is a potential deadlock even when no run hit it. Go's race detector does not report lock-order cycles.
Production binaries never import this package: the overlay exists only in the journey build.
A lock's class is the declaration the overlay rewrote it from: every instance of one struct field (or variable) shares a class, like the classes of the Linux kernel's lockdep. Embedded locks and locks created through a composite literal have no declaration to name and use the call site of their first acquisition instead. A cycle fails the run when it is real for the objects involved: either the same lock instances were taken in opposite orders, or every class on the cycle has only ever had one instance (a singleton such as a session or mode lock). A class cycle among classes with several instances (nested containers of one type) is only a candidate, written to the report file with the suffix .potential, because two different parent and child objects of one type can interleave without ever contending.
Index ¶
- type Mutex
- type RWMutex
- func (m *RWMutex) Lock()
- func (m *RWMutex) LockAs(site string)
- func (m *RWMutex) RLock()
- func (m *RWMutex) RLockAs(site string)
- func (m *RWMutex) RLocker() sync.Locker
- func (m *RWMutex) RUnlock()
- func (m *RWMutex) TryLock() bool
- func (m *RWMutex) TryLockAs(site string) bool
- func (m *RWMutex) TryRLock() bool
- func (m *RWMutex) TryRLockAs(site string) bool
- func (m *RWMutex) Unlock()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Mutex ¶
type Mutex struct {
// contains filtered or unexported fields
}
Mutex replaces sync.Mutex.
func (*Mutex) LockAs ¶
LockAs locks m as a member of the class declared at site; "" names the caller's call site.
type RWMutex ¶
type RWMutex struct {
// contains filtered or unexported fields
}
RWMutex replaces sync.RWMutex.
func (*RWMutex) RLock ¶
func (m *RWMutex) RLock()
RLock read-locks m. Recursive read locking on one goroutine is allowed and not reported.
func (*RWMutex) TryRLockAs ¶
TryRLockAs is TryRLock with an explicit class site.