Expand description
Happens-before edges: a sparse, authored partial order over dynamic events.
Where --replay-schedule-from replays a complete total order captured from
a prior run, a happens-before specification pins down only the few events
that matter for a race and lets the deterministic scheduler fill in the rest.
An agent (or human) that already knows a target race can therefore construct
it deterministically instead of blind seed-search.
§Model
An Anchor names a precise, deterministic per-thread stop point. Following
the owner’s refinement of RFC #1146, the primary addressing is a
Position — “after N syscalls” or “after M retired conditional branches
(RCBs)” on a specific thread — optionally decorated with a CodeLocation
(function and/or source line, resolved from debug info) for readability. The
RFC’s richer addressing modes (Nth occurrence of a named syscall, RIP hit, or
function entry) remain expressible but are deliberately not the lead
addressing scheme.
A HappensBeforeEdge states that one anchor must be observed before another
thread is allowed to proceed past its anchor. A HappensBeforeSpec is the
whole authored partial order: a table of named threads, a table of named
events (anchors), and the edge list connecting them.
This module owns the model only: parsing (JSON and a terse DSL),
normalization, and static validation (name resolution, exactly-one-position,
and cycle detection). Resolving a CodeLocation to a concrete address via
debug info, and enforcing edges in the scheduler, live in higher layers.
Structs§
- Anchor
- A fully normalized anchor: a named, deterministic per-thread stop point.
- Code
Location - A source-level location, resolvable to/from an address via debug info.
- Edge
Spec - One ordering constraint:
beforehappens-beforeafter. - Event
Spec - A single named event (anchor) in the declarative format.
- Happens
Before Edge - A normalized happens-before edge between two anchors.
- Happens
Before Program - A validated, normalized happens-before program: anchors indexed by name plus the edge list, guaranteed acyclic with all references resolved.
- Happens
Before Spec - The declarative happens-before specification, as read from a JSON file or desugared from the terse DSL. This mirrors the reviewed RFC #1146 file format verbatim so an authored file round-trips.
- HbThread
Counters - One thread’s happens-before counting state: its occurrence counters, and for each relative anchor whose base this thread has reached, the origin: the count of the relative anchor’s counter just after the base entry. Belongs to the thread, like its syscall count: empty for a new thread, kept across the thread’s own exec.
- Thread
Ref - A resolved reference to a thread.
- Thread
Spec - How a symbolic thread label resolves to a concrete
DetTid.
Enums§
- Happens
Before Error - An error produced while parsing or validating a happens-before specification.
- Phase
Spec - Serializable mirror of
SyscallPhaseusing lowercase author-friendly names. - Position
- The deterministic per-thread stop point that an anchor addresses.
- Strength
- How strictly an edge is enforced by the scheduler.
Constants§
- DEFAULT_
MAX_ HOLD_ NS - The hold budget of a version-2 spec that sets no
max_hold_ns: 10 s of virtual time. - HAPPENS_
BEFORE_ VERSION - The newest schema version understood by this build. Version 2 adds
relative anchors (
from), thefutex_opfilter and the hold budget (max_hold_ns); version 1 files load unchanged, with their old semantics. A build that understands only version 1 refuses a version-2 file instead of silently dropping the fields it does not know. - HAPPENS_
BEFORE_ VERSION_ 1 - The original schema version, still accepted. It may not use any field that
version 2 added (
HappensBeforeError::NewFieldInVersion1).
Functions§
- syscall_
never_ reaches_ tracer - True for a syscall that never reaches Hermit’s tracer on the ptrace
backend, whatever Detcore subscribes to: Reverie lets
rt_sigreturnrun untraced from its private page so a signal frame is restored safely. A syscall anchor on one could never fire, so the run refuses it. - syscall_
never_ returns_ on_ success - True for a syscall that does not return to its caller when it succeeds: the exec family replaces the image, and the exit family ends the thread. A posthook anchor on one is refused at load.
- syscall_
takes_ fd_ first - True when
sysno’s first argument is a file descriptor, so an anchor may restrict it withfd. The list is the fd-first syscalls a guest is likely to anchor on; anfdon any other syscall is refused when the spec is loaded rather than matched against an argument that is not a descriptor.
Type Aliases§
- Occurrence
Counters - One thread’s syscall-occurrence counters
(
HappensBeforeProgram::count_syscall_occurrences). - Occurrence
Key - The key of one per-thread occurrence counter: a syscall number, an optional
file descriptor and an optional futex operation (
Anchor::occurrence_key).