You are on page 1of 2

ONLINE

Global news for the creators of technology

Static analysis stomps on bugs


By Richard A. Quinnell
March 6, 2008

R
FO
Static source code analysis tools have errors, identifying problem
evolved from simple syntax checkers to areas for programmers to

T
O
powerful tools for identifying flaws in the examine more closely. This

.N
complex interactions of large code bases. algorithmic approach elimi-

LY
Until recently, however, they were mainly nates the need for test cases;

N
used by quality assurance teams to evalu- the algorithms alone determine

O
ate code during integration builds near how effectively the analysis dis-

G
project completion. covers errors. But the approach
IN
The latest product introductions are now also raises the possibility of
D
A

moving these tools back into the hands of false identification: code
E
R

developers to help detect software errors flagged as being in error that


L

much earlier and before they propagate. will, in fact, execute correctly. If
A
N

Klocwork’s Insight and GrammaTech’s they generate too many false


O

CodeSonar Enterprise both address devel- positives—exhibit low “preci-


S
R

oper needs by providing utility even when sion,” in the tool vendors’
E
P

many code segments are still missing. terms—static tools can over-
R

Software development teams have two whelm users with follow-up


. O
N F

types of tools available for automating the tasks, obscuring the real errors. expectations, only procedure, and so will
IO Y

detection of errors in their code. One type The two tool types are complementary in identify potential problems without bias.
T P
U O

uses dynamic analysis, which watches that each excels at finding errors that
IB C

code as it is being executed. The other cause the other difficulty, but dynamic Forward in development cycle
R D

type uses static analysis, which algorithmi-


T TE

analysis has seen more use among devel- Until recently, static source code analysis
cally examines code for errors. Both types opers. This is partly because early static tools were useful only late in the develop-
D RIN

have advantages and limitations. analysis tools were little more than syntax ment process, at the integration build
P
IS

Dynamic analysis is good at finding run- checkers that developers used to find rela- stage, when they had full access to all code
time errors such as resource leaks and tively simple coding and style errors. segments. A number of recent releases,
dynamic memory corruption. Developers In the last decade, however, static analy- however—including Klocwork’s Insight and
can also be certain that any errors a sis tools have become more productive as GrammaTech’s CodeSonar Enterprise—
dynamic analysis tool reports are real, research has yielded more-effective algo- have added features to put static analysis
because they were found during actual rithms. They have gained an ability to iden- tools into the hands of developers for use
code execution. tify a host of subtle errors (see table on as code is still being generated.
But to use dynamic analysis effectively, back), many of which only manifest as exe- This new generation of static source code
the code must be thoroughly exercised, cution problems during task interleaving in analysis tools utilizes the enterprisewide
which requires the use of test cases. Thus, a preemptive multitasking environment. software development environment to
the effectiveness of dynamic analysis at One of the side benefits of the new static combine the efforts of development teams
finding errors depends on the quality of the analysis capabilities is the enhanced ability working on different parts of the same proj-
tests being run. Further, because dynamic to find weaknesses in code that malicious ect (see figure). By allowing the peer-to-
analysis tools work with running software, users could exploit to circumvent security peer exchange of information regarding
they come into play only late in develop- safeguards. It is easy for developers to analysis scans of code segments, the tools
ment, when code is already written and underestimate software security vulnerabil- gather the wider context needed for preci-
first being integrated. ity, because they expect code to be operat- sion in error detection.
Static analysis uses an algorithmic ed normally. The algorithmic approach of This wider context, coupled with auto-
approach to examine source code for static analysis tools, however, has no matic modeling of missing code, quickly
This early use of static analysis, however, basis. “Different teams are prepared to
must be handled with an understanding of accept different levels of false positives,” said
the limitations stemming from its partial GrammaTech’s Anderson. “A safety-critical
view of the code. “It is important to remem- project may be willing to tolerate a 10:1
ber that in the early stages of software false:true error report ratio, while for other
development, the tools are imprecise and projects a 50:50 ratio is a problem because
can miss interprocedural effects,” cau- of wasted time tracking down false errors.”
tioned Paul Anderson, vice president of K l o c w o r k ’s
engineering at GrammaTech. Fisher said,
Anderson added, however, that the “Some of our
results improve as the body of analyzed customers start
code grows. Frequent early use of static using the tool
analysis can also help train developers to on day one,
recognize weaknesses in their individual when the tool
coding styles and adapt their approach to starts relatively
prevent repeating the same types of errors. weak. They sim-
Because tools in this new generation are ply tolerate the
put to use by the entire project develop- extra false posi-
ment team, they can build a history of tives. Others
analysis results to help identify new prob- prefer to take

R
FO
lems as they arise. Klocwork’s Insight, for the cost of wait-
instance, saves data from each analysis ing for the archi-

T
O
run, allowing developers to track flagged tecture to be

.N
errors throughout the development cycle, fully developed,

LY
said Gwyn Fisher, the company’s chief even though

N
technical officer. then, the defect

O
The tool also allows authorized senior density is high.”

G
developers to tag errors as false positives
IN Ultimately, project teams must decide
or as irrelevant, Fisher added, so that for themselves how to balance the cost of
D
A

future analysis runs do not report them. false positives early in the process
E
R

This helps the development team concen- against the cost of finding and correcting
L

builds a sound basis for developers to trate on real errors and makes more visible errors late in the process. However teams
A
N

check their code against, even while the any newly introduced errors or ones that choose to handle static analysis, though,
O

project remains incomplete. Errors caught arise when interacting code sections are the tools have proven to be a valuable
S
R

at this stage are much easier and cheaper analyzed together. asset in finding code defects and securi-
E
P

to correct than those caught later in devel- ty weaknesses. Now that the tools are
R

opment. Further, catching errors early pre- When to go static back in the developers’ hands so defects
. O
N F

vents them from propagating through the How early in the development process and are found earlier, static source code
IO Y

system to affect the behavior of code how often to use static code analysis is a ques- analysis can help lower the cost of devel-
T P
U O

developed later. tion best answered on a project-by-project opment, as well.


IB C
R D
T TE
D RIN
P
IS

(#16348) Reprinted with permission from the March 6, 2008 online edition of Electronic Engineering Times. Copyright 2008 United Business Media LLC.
For more information about reprints from Electronic Engineering Times, please contact PARS International Corp. at 212-221-9595.

You might also like