Shape analysis through predicate abstraction and model check(10)

时间:2025-04-10

Abstract. We propose a new framework, based on predicate abstraction and model checking, for shape analysis of programs. Shape analysis is used to statically collect information — such as possible reachability and sharing — about program stores. Rather t

ande2withtypest1andt2resp.Thispropertyallowsthesimpli ertoreplaceapredicateoftheformreach[A;F](e1,e2)byfalseiftypreach[F](t1,t2)failstohold.(Otherwise,nothingisreplaced.)Typereasoningisalsousedtosimplifyequalities;e.g.(x==y)isfalseifthetypesofxandydi er.

5AnExample

Weillustrateourapproachonaprogramforin-placereversalofsingly-linkedlists,alsoconsideredine.g.[4,24,33,28,29].ThecoreoftheprogramisgiveninFigure6.

Listx,y,t;/*xisanacycliclist*/

n1:y=NULL;

n2:while(x!=NULL){

n3:t=y;

n4:y=x;

n5:x=x->n;

n6:y->n=NULL;

n7:y->n=t;};

n8:

Fig.6.Thelistreversalprogram

Initially,xisthelisttobereversed.Itistraversedheadtotail,reversingthenext-pointers(n)onebyone.Atthestartofeveryiterationofthewhileloop,xistherestofthelisttobereversedandyistheinitialsegmentthathasbeenreversedsofar.Variabletisauxiliary;atanypointduringthereversal,itpointstooneofthe ingshapeanalysis,wewanttoverifythatyisanacycliclistafterthereversal(usingthenegationofpredicatep1=cyclic[;n]y@n8),giventhepreconditionthatxisacyclic(p2=cyclic[;n]x@n1).

Werunourtoolon(the ow-chartdescriptionof)theprogramtogetherwithpredicatesp1andp2,butwithoutanyapproximation.Bychoosingarelativelylargeiterationbound,predicatesaregeneratedthatoccurinwp’sobtainedbypropagatingp1backwardsthroughthesequenceofstatementsofthewhileloopforaseveraliterations(p2,beingatn1,doesnotgenerateanynewpredicates).Bymanuallyinspectingthesepredicates,wecangetanideaoftheappropriateapproximationstobeapplied.Settingtheiterationboundto30,185predi-cate/locationpairsarecalculatedcorrespondingtoabout3backwarditerationsthroughthewhileloop.Allpredicatesareoftypecyclic,reach,orequality;theydi erintheirarguments.Thefollowingisanexcerptfromthetool’soutput,showingsomepredicatesrelevantatlocationn5.

Shape analysis through predicate abstraction and model check(10).doc 将本文的Word文档下载到电脑

精彩图片

热门精选

大家正在看

× 游客快捷下载通道(下载后可以自由复制和排版)

限时特价:7 元/份 原价:20元

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219