Program Analysis Tools Flashcards
Why are bugs costly to fix?
The longer it’s hidden, the more code may rely on it
Finding the root cause is difficult after the fact
Why do tests not catch all bugs?
Testing is best effort at best
What are some proactive ways to prevent bugs from appearing?
Search for known classes of bugs
Guard against certain classes of bugs
Prove that certain bugs are not present
Identify bad styles that may lead to bugs
What is program analysis?
Tools and techniques that allows computers to automatically reason about the program’s behaviour
Why would we want to push program analysis onto computers?
Computers excel at repetitive, subtle behaviour
Why are errors like Apple’s goto fail issue so hard to catch for humans even though simple program analysis tools would be easily able to find it.
People are bad at identifying subtle details. Computers will analyze everything line by line with glossing over anything
What are the 2 main categories of program analysis tools?
Dynamic and static analysis
What do dynamic analysis tools do? What is it best used for? What are some examples?
Run the program under test and reason about that single execution
Best used for explaining bugs that are already happening
Debuggers, valgrind
What do static analysis tools do? What is it best used for? What are some examples?
Examine source code/binary and reason about all possible executions
Best used for identifying bugs that haven’t struck yet but might in the future
What are the limitations of dynamic approaches? How about static approaches?
Dynamic: As it’s driven by a single input, it will miss bugs caused by other inputs (false negatives)
Static: Because of undecidibility, it cannot be totally sure that there is a problem when it detects one (halting problem) (false positives)
Most large companies are finding __________ to be unacceptable, which makes static approaches less widely used
false positives
What does Valgrind use to analyse code?
Dynamic Binary Instrumentation. It’s like JVM for machine code
What are some built in tools for Valgrind?
Memcheck, cachegrind, helgrind
What does Valgrind not work for Java or Python by default?
Valgrind modifies a compiled C binary to check for errors, not other binaries
What do Clang sanitizers use to analyse code?
Compile time instrumentation and rewrites the program once to perform analyses every time it executes