Software has been under scrutiny by the verification community from various angles in the recent past. There are two major algorithmic approaches to ensure the correctness of and to eliminate bugs from such systems: software model checking and static analy
Figure3.Fragmentsof(a)theattributedabstractsyntaxtree(AST),and(b)theannotatedcontrol owgraph(CFG).
123456789101112
voidf(intx){inta,b;int*p;
p=(int*)
malloc(sizeof(int));*p=42;
if(x==0){free(p);a=*p;}
b=a+*p;}
modelchecking.ConsiderthecontrivedcodefragmentinFigure2,whichisobviously awed.Notonlydoesitcon-tainapotentialaccessofanuninitializedvariable(ainline11),butalsodereferencesapointerthathasalreadybeenfreed(pinline9),andassignsavaluetoavariablethatisneverusedafterwards(binline11).
WewillillustratethelabelingoftheASTandCFG,thegenerationofNuSMVcodethatimplementsthechecksandtheeaseofaddingpropertiestoGoanna.Again,wedemon-strateitinthecontextofuninitializedvariablesforthesakeofsimplicity.
4.1AnnotationofCFG
Figure2.Sourcecodeexample
Theprogramanalysisbuildsonanannotatedcontrol owgraph.Generatingthecontrol owgraph—withoutannotations—forthecodefragmentisstraightforward.AfragmentoftheASTisdepictedinFigure3(a)andthere-sultingCFGinFigure3(b).EachnodeislabeledwithanIDandalabel.TheIDsrefertoidenti ersintheintermedi-ateformatgeneratedbytheparserandareusedfortechnicalreasonsonly.TheattributesofnodesintheASTareusedtolabeltheedgewiththeparentnodeinFigure3(a).OnlynodesoncertainlevelsintheASTwillbeusedtobuildtheCFG,inthisexamplenodes59,63,72and78.5

