Verifying: fire verify
fire verify checks the UPPAAL model fire build wrote against the
project’s queries, with UPPAAL’s verifyta. The model assumes the
contracts of the imported code, so it proves those first. It never
writes the model: run fire build first, and again after a source
changes.
Usage
fire verify [PROJECT_DIR] [-q <QUERY_FILE>] [-o <OUTPUT_FILE>]
| Argument / flag | Description |
|---|---|
PROJECT_DIR | The directory holding fire.toml. Defaults to the current directory. |
-q, --query <QUERY_FILE> | One query file, instead of every .q in <src>/spec/. |
-o, --output <OUTPUT_FILE> | Also save the report as plain text, even when the run fails. |
What it does
-
Reads
fire.tomland resolves the source directory. -
Proves the imported code’s contracts with the code verifier for each language that has any: Frama-C for annotated C,
pancake2viperfor Pancake. Files without contracts have nothing to prove. A header’s contracts are proved on the project’s.cfile of the same name, which includes it (include/eth.honsrc/eth.c); an annotated header with no such source is an error. A C function named in the entry’sassumeis not proved: its file gets anASSUMEDrow naming it. Rows name a file by its path in the project.A contract can also be on a function that none of those files defines, such as a library routine. Frama-C uses such a contract at each call but cannot prove it.
fire verifylists these functions in a row for the header that declares them:EXTERNALforinclude/gen/mem.h, the memory routines fic links into every PD. fic proves their contracts itself.ASSUMEDfor any other header. Nobody proved these contracts.
fic’s proof holds only for the
gen/mem.hthat fic generates. If the file has been changed, the run fails on a row naming it;fire buildwrites the file again. -
Reads
build/<name>.xta. The--prettyXML is for the GUI only. -
Runs
verifyta([verify.model_checker] path, then$VERIFYTA, thenPATH) on the model and each query file, asking for a trace. -
Prints one PASS / FAIL line per contract file and per query, and exits non-zero if any check fails, or if
verifytaanswered fewer queries than a file holds (a refused licence, a crash).
With -o, each part’s rows are followed by one line with the tools’ own
figures. For C contracts:
verify contracts demo: datadiode result: PASS files: 3 functions: 9 goals: 110/110 assumed: 9 external: 6
functions: the functions whose contract Frama-C proves on their body. A contract is the annotation on one function.goals: the facts WP proved, of those it had to. One contract takes several goals, and-wp-rteadds one for each operation that could fail at run time.assumed: the functions that are not proved, named inassumeor declared by a header no proved file gives a body for.external: the functions ofinclude/gen/mem.h, which fic proves.
assumed and external are left out when they are zero, and functions
when the fic-acsl plugin is not installed.
Writing queries
Which properties matter depends on the application, so fic emits only
the model and you write the queries: a
UPPAAL query file
in <src>/spec/, part of the project’s sources.
Queries name the process instances of the model (the PD names) and
their locations; a PD’s variables keep their names, and a struct’s field
is pd.var.field. Read build/<name>.xta, or open the --pretty XML in
the UPPAAL GUI, to find them.
Buffered channels in the model
A buffered channel c is a queue q_c holding its length (in place of
the ring’s two indices), signalled (as filib’s signal word: false while
the receiver asks to be notified) and capacity, plus pend_c, Microkit’s
pending notification. Its values are q_c_val, oldest first. A PD that
receives on one has a local awake:
- a send that fits stores its value at
q_c_val[q_c.length], adds one and, if the receiver asked, setspend_c; on a full queue it is lost; - a receive needs
awake && q_c.length > 0, takesq_c_val[0]and shifts the rest down; - at a resume point the PD parks (
awake = false, asking on each buffered arm) when no arm is enabled, and wakes on a pending notification.
So A[] not (!rx.awake && q_c.length > 0 && !pend_c) states that no
wake-up is lost.
An IRQ is raised by the Environment template for ever, as a test harness
keeps feeding a device, and handled as seL4 handles it: a raise sets
irq_N_pend, which the PD’s irq?N takes, and masks the IRQ
(irq_N_masked) until the driver acks it with irq!N, so the device
raises again only after the ack. What the device delivers comes from the
driver’s contracts (see
Contracts).
The device always has a move unless a driver never takes or never acks its
IRQ, so A[] not deadlock states that no driver is stuck on its IRQ. A receiver stuck
on a buffered channel while others run is not a deadlock: the lost-wake-up
query above catches it. Each queue holds at most 3 in the model (its capacity if
smaller). A result that holds there holds of the real capacity once the
small-capacity argument is proved
(#601, obligation 6).
A struct in the model keeps its fields but its arrays: a .fi program
never indexes one, so no guard reads it. A call whose contract fixes a
field of its result (ensures \result.origin == origin) sets that field
and leaves the others as they were.
That is enough for secrecy, a reachability query. demo/datadiode’s
Frame carries origin, the network it came in on, which eth_frame’s
contract fixes; A[] not (... dd.f.origin == ORIGIN_INNER ...) states that
no frame from the inner network reaches a PD on the outer side, in any
variable or queue slot.
Worked example: ping-pong
demo/pingpong/ has two PDs, ping and pong, which bounce a
notification ROUNDS times over a cyclic channel (ping <-> pong) and
then stop. WF2 would reject the cycle, so the manifest sets
allow_wf2_cycles and spec/pingpong.q decides deadlock freedom
instead:
$ fire verify demo/pingpong/
fire: verifying pingpong
✓ Running frama-c: /usr/local/bin/frama-c
ACSL: pingpong.c PASS
✓ Running verifyta: /opt/uppaal/bin/verifyta
✓ Query file: demo/pingpong/spec/pingpong.q
Q1 A[] (deadlock imply ping.rounds == ROUNDS) PASS
Q2 E<> ping.rounds == ROUNDS PASS
Q3 A[] ping.rounds <= ROUNDS PASS
Q4 E<> pong.L2 PASS
Q5 A<> ping.rounds == ROUNDS PASS
Q1 is deadlock freedom up to the intended end: the finished rally is a
state where both PDs wait, so a plain A[] not deadlock would fail on it.
Q5 says the rally finishes on every path.
Reading a failure
A failing query prints FAIL and, when verifyta produces one, the
trace:
Q1 A[] not deadlock FAIL
Trace (12 steps):
...
↯ stuck at: ping.L1, pong.L2
The ↯ stuck at line gives each automaton’s location in the deadlocked
state, usually enough to spot the circular wait. A reachability query
that fails with (property unreachable — no counterexample trace) names
a state that can never be entered.