lockorder

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 10 Imported by: 0

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

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) Lock

func (m *Mutex) Lock()

Lock locks m.

func (*Mutex) LockAs

func (m *Mutex) LockAs(site string)

LockAs locks m as a member of the class declared at site; "" names the caller's call site.

func (*Mutex) TryLock

func (m *Mutex) TryLock() bool

TryLock tries to lock m.

func (*Mutex) TryLockAs

func (m *Mutex) TryLockAs(site string) bool

TryLockAs is TryLock with an explicit class site.

func (*Mutex) Unlock

func (m *Mutex) Unlock()

Unlock unlocks m.

type RWMutex

type RWMutex struct {
	// contains filtered or unexported fields
}

RWMutex replaces sync.RWMutex.

func (*RWMutex) Lock

func (m *RWMutex) Lock()

Lock write-locks m.

func (*RWMutex) LockAs

func (m *RWMutex) LockAs(site string)

LockAs write-locks m as a member of the class declared at site.

func (*RWMutex) RLock

func (m *RWMutex) RLock()

RLock read-locks m. Recursive read locking on one goroutine is allowed and not reported.

func (*RWMutex) RLockAs

func (m *RWMutex) RLockAs(site string)

RLockAs read-locks m as a member of the class declared at site.

func (*RWMutex) RLocker

func (m *RWMutex) RLocker() sync.Locker

RLocker returns a Locker for the read lock.

func (*RWMutex) RUnlock

func (m *RWMutex) RUnlock()

RUnlock read-unlocks m.

func (*RWMutex) TryLock

func (m *RWMutex) TryLock() bool

TryLock tries to write-lock m.

func (*RWMutex) TryLockAs

func (m *RWMutex) TryLockAs(site string) bool

TryLockAs is TryLock with an explicit class site.

func (*RWMutex) TryRLock

func (m *RWMutex) TryRLock() bool

TryRLock tries to read-lock m.

func (*RWMutex) TryRLockAs

func (m *RWMutex) TryRLockAs(site string) bool

TryRLockAs is TryRLock with an explicit class site.

func (*RWMutex) Unlock

func (m *RWMutex) Unlock()

Unlock write-unlocks m.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL