Skip to main content

Module guard

Module guard 

Source
Expand description

Deadlock guards: how a test that hands work between threads turns a hang into a failure without timing the code it tests.

A test of a lock rule (a callback that re-enters the core, a thread that holds a lock another thread’s callback needs, a rendezvous) hangs for ever when the code under test deadlocks or never ends, so it waits with a limit and fails past it. The limit is no measure of the code: a correct run answers at once, and DEADLOCK_GUARD is ten minutes, beyond any delay a loaded machine’s scheduler adds, so only a hang reaches it, and each failure says that it is this guard. A hook that holds a thread at a point until the test lets it go (hold) waits as long, so load never lets it go early. unguarded finds a timed wait that does not take its limit from here (review round 3: guards of 10 s could fail on a loaded machine).

Constants§

DEADLOCK_GUARD
How long a deadlock guard waits: ten minutes.
TIMED_WAITS
The calls that wait with a time limit: a channel’s, a condition variable’s, a park’s.

Functions§

finishes
Runs f on a thread of its own and returns what it returns, failing as recv does; past the guard the thread is left behind, not waited for.
hold
Holds the calling thread (a test’s hook) until the test lets it go, a message on rx, or drops the sender (it is done with the thread).
recv
rx’s next message, waited for at most DEADLOCK_GUARD; what names what the test waits for, and what a lock held where it must not be would deadlock.
unguarded
Every file:line of a .rs file under root (target directories left out) that calls a TIMED_WAITS wait in a file that never names DEADLOCK_GUARD, whose limit therefore comes from somewhere else. Comment lines are not scanned. The engine’s early exit line (unityrs_batch::progress::early), whose wait is the contract’s own bound, is left out for its one wait only: a count there other than one is reported as <file>: <n> timed waits, the exemption is for one; so is the same line’s writer on a descriptor it could not duplicate (unityrs_batch::sys::borrowed). Execution’s two production startup deadlines, two channel-priming waits and one startup-gate priming wait are exempted by their exact count; a sixth wait is reported. Normal progress (progress/live.rs) is exempted for its heartbeat, its final acknowledgment and one startup priming wait.
wait
Waits for a signal on rx (a thread has reached a point), as recv.