Definition
A concrete state is a complete snapshot of a running program at one moment: the exact value of everything that, in a chosen model of execution, determines what the program can do next. For a simple machine it consists of the position of the next instruction, the content of every register and the content of every memory byte. “Concrete” is the opposite of “abstract”: static analysis §3.1 computes with abstract states, summaries that each stand for a set of concrete states. The model, not the program, fixes the components.
The idea
Every question about what a program can do is a question about the states it passes through. “Can this load read outside its buffer?” asks whether some reachable state §3.21 has the load as its next instruction and an address outside the buffer. To answer, the state must hold everything that the answer depends on. “The program is at instruction 5” is not enough: what instruction 5 does depends on register values, on memory, and on whether the buffer it reads still exists.
A chess position is a good picture. The placement of the pieces, plus whose turn it is, determines nearly every legal next move, and anyone can continue a game from a recorded position. The picture also shows the trap. Whether a player may still castle depends on whether the king or that rook has moved earlier, which the placement does not show, so a complete chess position also records the castling rights. A program model must likewise record every hidden fact that the next step depends on.
How it works
A model of execution fixes three things.
The components of a state. Typically:
the program counter §2.9, the position of the next instruction;
the registers;
memory, as a map from addresses to bytes;
which memory belongs to live objects, and with what permissions (read, write);
the call stack, the active function calls and the positions to return to;
counters that the runtime keeps, such as fuel §2.32, the number of instructions the program may still execute;
the environment: input buffers, persistent state §8.1 kept in storage, clocks, device registers, and anything another thread or device can change.
The initial states, in which a run may begin.
The step relation, which gives, for each state, the set of possible next states. If every state has exactly one next state, the model is deterministic. If an input, the result of a called function or a thread schedule can differ, a state has one next state per possibility, and the model is nondeterministic.
A run is a sequence of states, each a possible next state of the one before. The reachable states are all states that some run reaches. Dynamic analysis §3.2 observes runs. Static analysis computes summaries of the reachable states.
Worked example
A small machine is about to execute instruction 5, which loads one byte from an input object, at the offset held in register R1, into register R0. The state before the step:
program counter 5,
R0,R1, fuel 3;input object: the 4 bytes 10, 20, 30, 40 at positions 0 to 3, live.
The offset 2 lies in 0 to 3, so the step is allowed. The next state has program counter 6, R0 (the byte at position 2), R1 , fuel , and the same input object.
Change one component. The input object has been freed, and its memory now holds another object with the bytes 7, 7, 7, 7. The program counter, the registers and the fuel are unchanged. A model that records which objects are live sees a read from a freed object and moves to an error state. A model that records only addresses and bytes predicts R0 and a normal step. That second model cannot see the use-after-free §4.6, because the component that tells the two situations apart is missing from its states.
Instruction 6 calls a helper function §2.19, a routine that the runtime provides, which can return 0 or 1. From the one state before the call, the model has two possible next states, one with R0 and one with R0 . Each run takes one of them.
Even a tiny machine has many states. With 8 instruction positions, two 8-bit registers and 4 bytes of memory, there are , about , states. This count is why static analysis works with summaries.
Stated precisely
Write a concrete state as . Here is the program counter, maps each register to its value, maps each address to a byte, is the set of address ranges of live objects with their permissions, is the remaining fuel, and is the state of the environment. A model is a set of initial states and a step relation , where means that is a possible next state of . A state is reachable when there are states with and for each from 1 to .
The choice of components is adequate for a property when two conditions hold.
The set of possible next states of every state is determined by the state alone: every outside influence is either recorded in or listed in the step relation as a choice that can go any way the real environment can.
Whether a step violates can be decided from the states before and after it.
If a component that influences the next step is left out, two different real situations become one model state, and a proof about the model can miss a behavior that the real system has.
Limits and common mistakes
Concrete means concrete relative to the model. A model for checking array §14.5 bounds needs no voltages or cache contents. A model for proving that timing reveals no secret, the absence of a timing side channel §1.29, must include the cache, because cache contents change how long a load takes.
Leaving a component out is safe only when no claimed property depends on it, or when the model lets the component take every value it can really take, as an arbitrary input. Fixing the component to one assumed value, such as “the clock never wraps” or “allocation never fails”, is a hidden assumption, and a proof that relies on it fails when the assumption does.
Some properties depend on history, for example “a counter value is never accepted twice”. The state must then record the history needed, as the castling rights do in chess.
Concurrency §9.1 changes the step relation, not only the state. An interrupt handler §6.12, another core, or a direct memory access §4.36 (DMA) transfer, in which a device writes memory without the processor, can change memory between any two instructions of the program.
Questions answered
Which environmental state is omitted from your semantics?
The answer is a list: every influence on a program’s next step that the model’s concrete state, its snapshot of the running program, does not record and that the model does not treat as an arbitrary input. Making that list is the point of the question. Common omissions are:
clock and timer values, including counter wraparound §6.21;
interrupts §6.11 and the moments at which they arrive;
other threads, cores and devices that write shared memory, including direct memory access (DMA) transfers;
device registers whose value changes over time or when read;
failures and error returns of called functions, such as an allocation that fails;
which memory is live, and whether freed memory has been reused;
the true length and content of inputs, not only the ones tested;
persistent state left by earlier runs or earlier versions, and resets or power loss in the middle of a write;
hardware effects below the instruction level: caches and speculative execution for side channels, and bit flips.
For each item, do one of three things: add it to the state, model it as an arbitrary input limited by a stated contract, or argue why the property being proved cannot depend on it. A state that omits an influence without such an argument is not complete for that property.
Related entries: Virtual machine (VM) (§2.3), Abstract interpretation (§3.4), Reachability (§3.21), Program counter (PC) (§2.9), Instruction budget (fuel) (§2.32), Use-after-free (§4.6).