Verification and Testing Flashcards
Soundness
No incorrect programs are deemed correct ( ⇒ All errors are found)
Completeness
A correct program is deemed correct ( ⇒ no spurious errors)
Static verification
Consider program code, check
for all possible executions
Dynamic verification
Runtime verification of executions
Deadlocks
A deadlock is a circular wait
show themselves when a program hangs
hard to find because they often occur only with a specific scheduling
hard to reproduce
Race conditions
two or more threads can access shared data and they try to change it at the same time
If the result of an execution depends on the execution order of two threads, one says that there is a race condition
data race
- Two threads access variable concurrently
- At least one access is write
- Nothing prevents simultaneous access
gate lock
A gate lock prevents a deadlock by protecting the areas with lock reversal
Lock Tree Algorithm
Dynamic algorithm to find deadlocks
in a tree, keep track the order in which locks are
acquired and released; see if there are reversals
Limitations
• Works for deadlocks involving two threads only
• Works only for properly nested locks
T1
ALock
BLock
T2
BLock
ALock
Lock Tree Algorithm - steps
Build trees during runtime
– each tree has a current node
– If lock acquired create new child and move to it
– If node released, move up one level
After termination, analyze trees. Possible deadlock if
- T1 contains a node Li with ancestor Lj
- T2 tree contains a node Lj with ancestor Li
- There is no gate lock: node Lk which is an ancestor of Li in T1 and Lj in T2
A gate lock is a lock that is
- an ancestor of Li and Lj in T1 and
- an ancestor of Li and Lj in T2
Eraser
finds possible race conditions
Check locking behavior
For any shared data, is some lock always held on
access?
This condition is sufficient but not necessary for
correctness
Dynamic algorithm
– Computes locks held during one run
– May not find all problems
– May warn when no problem exists
– What it finds depends on the run!
Why is eraser better at finding race conditions than simple testing?
Little dependence on scheduling order: Can find bug in
one scheduling by executing another one: better
than testing.
Read-write locks
- multiple simultaneous readers,
- a write is never simultaneous with another read or write
Valgrind
suite of tools, adds shadow memory
V-bits: One byte to store whether each bit has a valid value
A-bit: One bit to store whether byte has been allocated
Purify
simpler version of valgrind
uses two bits of status per byte of memory
faster than valgrind, becaue only one bit per byte