CSE 501 Principles and Applications of Program Analysis
Total Page:16
File Type:pdf, Size:1020Kb
CSE 501 ! Principles and Applications! of Program Analysis! " Alvin Cheung" Spring 15" Welcome to CSE 501!" The Cast" App–4 A. Cheung et al. Q, D, σ, h , e Q0, D0, σ, h0 ,(σ0, e ) h i i !h i i Q0, D0, σ, h0 , e Q00, D00, σ, h00 ,(σ00, e ) h i a !h i a force(Q00, D00,(σ0, e )) Q000, D000, v J K i ! i force(Q000, D000,(σ00, ea)) Q0000, D0000, va J K ! [Array deference] Q, D, σ, h , e [e ] Q0000, D0000, σ, h00 , h00[v , v ] h i a i !h i a i J K Q, D, σ, h , e Q0, D0, σ, h0 ,(σ0, e) Q000 = Q00[id (v, )] h i !h i ! ; force(Q0, D0,(σ0, e)) Q00, D00, v id is a fresh identifier ! [Read query] J Q, DK, σ, h , R(e) Q000, D00, σ, h0 , ([ ], id) h i !h i Semantics ofJ statements: K [Skip] Q, D, σ, h , skip Q, D, σ, h h i !h i J K Q, D, σ, h , e Q0, D0, σ, h0 ,(σ0, e) h i !h i Q0, D0, σ, h0 , el Q00, D00, σ, h00 , vl h i !h i [Assignment] Q, D, σ,Jh , e := e KQ00, D00, σ[v (σ0, e)], h00 h i l !h l ! i J K J K Q, D, σ, h , e Q0, D0, σ, h0 ,(σ0, e) h i !h i force(Q0, D0,(σ0, e)) Q00, D00, True ! J Q00, D00, σ, h0 K, s1 Q000, D00, σ0, h00 h i !h i [Conditional–true] Q, D, σ, h , if(e) then s else s Q000, D000, σ0, h00 h i 1 2 !h i J K J K Q, D, σ, h , e Q0, D0, σ, h0 ,(σ0, e) h i !h i force(Q0, D0,(σ0, e)) Q00, D00, False ! Q00, D00, σ, h0 , s2 Q000, D00, σ0, h00 Jh iK !h i [Conditional–false] Q, D, σ, h , if(e) then s1 else s2 Q000, D000, σ0, h00 h J i K !h i J K Q, D, σ, h , s Q0, D0, σ0, h0 h i !h i [Loop] Q, D, σ, h , while(True) do s Q0, D0, σ0, h0 h i !h i Instructor" J K J K Q, D, σ, h , e Q0, D0, σ, h0 ,(σ0, e) h i !h i force(Q0, D0,(σ0, e)) Q00, D00, v ! update(D00, v) D000 J K ! D000[Q00[id].s] if Q00[id].rs = Alvin Cheung" id Q00 . Q000[id]= ; 8 2 Q00[id].rs otherwise ⇢ [Write query] Q, D, σ, h , W (e) Q000, D000, σ, h0 CSE 530! h i !h i J K Q, D, σ, h , s1 Q0, D0, σ0, h0 Q, D0, σ0, h0 , s2 Q00, D00, σ00, h00 " h i !h i h i !h i [Sequence] Q, D, σ, h , s ; s Q00, D00, σ00, h00 h i 1 2 !h i J K J K J ACM TransactionsK on Database Systems, Vol. V, No. N, Article A, Publication date: January YYYY. TA Extraordinaire! Andre Baixo! Office hours: TBD" You!" Course Communication" • Discussion board" – HW help" – Find project partners" • Course website: ! courses.cs.washington.edu/501 • Email: [email protected] Course Goals" • What are the techniques used to understand programs?" – Mix of classical and recent advances" • What can we use these techniques for?" – Variety of applications across different domains" • How do we build tools that utilize such techniques?" Course Goals" • How to do research?" – How to choose problems" – How to devise solutions" – How to evaluate" – How to report results" Course Non-Goals" • How to build a compiler from scratch" – Check out CSE 401" • What are all the compiler optimizations out there?" – Check out list of references on website" • Cover all research topics in program analysis" – 35 years of PLDI but we only have 10 weeks!" Class Format" • Two class meetings per week" – Tuesday and Thursday 11am – 12:20 pm" – Here!" • Occasional HW help and project feedback sessions" Class Format" • We will discuss 1-2 research papers during each class meeting" – Please read them beforehand" – We ask you to write a small commentary before class to share with everyone" – Be prepared to ask questions!" Grading" • Programming assignments (30%)" – Get to know available tools out there" – No late days" • Project (50%)" – Open-ended: find problems in your research area " – Work with a partner" – We will provide you with potential ideas" – Project milestones, end-of-quarter presentation, final report" • Paper summaries (20%)" – Submit paper summary 24-hrs before lecture" – See details on course website" Course Topics" • Dataflow frameworks" • Abstract interpretation" • Domain-specific languages" • Program verification" • Dynamic analysis" Course Topics" • Dataflow frameworks & abstract interpretation" – Pointer analysis" – Compiler optimizations" – Information flow" – Detecting malware" • Domain-specific languages" – Parallel programming" – High-performance computing" – New hardware" " Course Topics" • Program verification" – Finding program invariants" – Provably-correct compilers" • Dynamic analysis" – Program testing" – Model checking" • Compiler construction" Prerequisites" • Coding" • Data structures" • Mathematical logic" • [Optional] Knowledge about compilers" Now the fun begins…" Why understand programs?" • We all write code!" • It’s good to get some understanding about what we are coding" • It’s good to develop a formal framework for understanding programs" • It’s good to have somebody else do this for us, perhaps automatically" List of software bugs From Wikipedia, the free encyclopedia Many software bugs are merely annoying or inconvenient but some can have extremely serious consequences – either financially or as a threat to human well-being. The following is a list of notable software bugs with significant consequences: Contents 1 Space exploration 2 Medical 3 Tracking years In 1997, the Mars Pathfinder mission was jeopardised by a bug in concurrent software shortly after the 4 Electric power transmission rover landed, which had not been found in preflight testing because it only occurred in certain 5 Administration [5] u6n aTnetlieccipoamtemd uhneiacvayti-olnosad conditions. The problem, which was identified and corrected from Earth, [6][7] Februawr7ya Ms2 0dil0uit7ea ,rt yoa gcoromuppu otef rs rixes Fet-s2 2ca Rusaepdto brsy fplyriionrgit yfr oinmv eHrsiicokna.m AFB, Hawaii, experienced multiple compuTt8ehr Me c Ereadusirhaoepse caoni nScpidaceen tA wgiethn cthye'si rC crryoosSsiantg-1 o sfa ttheell i1te8 0wtha sm loesritd iina na olafu lnocnhg iftauidluer e(t hine 2In0t0e5rn dautieo ntoa la missing Date Lsi9hn ueVt)d.i doTewhoen g ccaoommminpmguatenrd f ianil uthre sf liingchltu cdoendt raot ll esaysstt enmav oigf aitsio Rn o(kcomt cpalrertieelry r olocskt)e ta.[n8d] communication. The figNh1At0e SrEsA nwc Mreyraepr tasio bPnleo ltaor rLeatunrdne tro w Haas wdeasiit rboyy efodl lboewcainugse t hitesi rf ltiagnhkt esrosf,t wsoamree tmhiinstgo othka tv mibirgahtito hnas vdeu be eteon pLrobilesma1tma1 t iooTcs rphafhan desrs ptihcoo ertt uawfrtbiteouanwltehnecra en rofot reb ee vebind egunocoegd .t hsTaht eth eer rvoerh wicales hfiaxde dla wnditehdin a n4d8 shhouutr so,f fa ltlhoew eingi na edse 4la0y medeters from From Wikipedia, the free encyclopedia deployFtmh1ee2eb n MrBut.au[2rsy9tiin] a2en0s s0u7r,f ac ger o(Dupe coefm sbixe rF 3-2, 21 9R9a9p)t.o[9r]s flying from Hickam AFB, Hawaii, experienced multiple Manyc s1oo3mf tRpwueIatftereser r s ecbinsruatcegserhss seapsr aecc omeicnercraeifdlty eM natna wnrsoi tCyhil nitmhge aoitrre c iOnrocrsobsniitnveger n woiefa ntsht aebl su1ot8 s0dotehms tmero ceyareind i,ha danvu oef et olxo tsnroegfmittwuedlayer e s( etohrnieo tuIhnset e cgronrnoasuteinoqdnuaelnces – either financially or as a threat to human well-being. The following is a list of notable software bugs with Date Line). The computer failures included at least navigation (completely lost) and communication. Medsiiagnificant cgoennseqrauteinngc ecso:mmands in pound-force (lbf), while the orbiter expected newtons (N). TAh me ifsig-shetnetr sc owmerme aanbdle f rtom re Etuarrnt hto c aHuasweda itih bey s ofoftlwloawrein ogf tthheei rN taAnSkAer sM, saorms Getlhoibnagl tShuatr vmeiygohrt thoa ivnec obrereenctly ISn pthae cpSasroeosnu byemle Bxem MptahtGlaicot ahCr amDado tcthioeopr wyhn aepdar etfhvaeeilrne ntdio, tnc ba suecesainn dga oilto (tdOo. cpTtoohiben ete ror r2no0er0 ow5f)a ,is tSs f oibxnaeytdt eB rwiMeisthG aitn pt h4roe8d shuuocnue.dr Ts ,ah aVilsl oacnwa uZinsaegnd ta t hdee lbaaytetedry music CD that emp[2lo9y] ed a copy protect[i1o0n][ 1sc1h] eme that covertly installed a rootkit on any Windows PC InC 19o9d7ntoe, tptohelvoeney Mrmhteasearnstt .(PNatohvfeinmdbeer rm 2i,s s2i0o0n6 w).as jeopardised by a bug in concurrent software shortly after the that waAs ubsoeods tteor pwlaeyn ti to. fTf hcoeiurr isnet ednutr iwngas l atou nhcidhe, rtehseu cltoinpgy ipnr othtec dtieosntr umceticohna noifs mN AtoS mAa Mkea irti nhearr d1e. rT thois was the rover laNnAdeSdA, 'ws hSipcihri th raodv neor tb beeceanm feo uunnrde sinp opnrseifvlieg hotn t eJastninugar bye 2c1a,u 2se0 0it4 o, nal yfe owc cwurereekds ianf tceerr tlainnding on Mars. circumrve1esnu Stl.tp Uoafcn etfh oeerx tfpualniolaurtareetli yoo,nf t ha et rraonostckriitb ienra tdov neortteicnetl ya no poevneerbda ar isne cau writryit theonl es precsuiflitcinatgio in fao wr tahvee g oufidance uMnanetdicEiipnaagtiende ehresa fvoyu-nloda tdh acto tnodoi tmioanns.y[5 f]i lTesh eh apdro abclceumm, uwlahtiecdh iwn aths ei dreonvteifri'es df lanshd mcoermreocrtyed. Iftr womas E reasrtho,red to [30] [1] succespsfr2uo lgM trraeomdjai,cn ra ehlsourlstien agt tianc tkhse o cno dthine gc oomf apnu tienrcso orrfe tchto fsoer [mw12uh]loa hina dit sin FnOocReTntRlyA pNla ysoefdt wthaer eC. D(J.uly 2 S2o, n1y9'6s2). working condition after deleting unnecessary files[.6][7] was due to computer resets caused by priority inversion. [2] subseqINun3eo tn thTete ret ahSfcfaooktn ritntyhsg eBt oyiMn epiatGriroas vlC irdDeep ocaor tupintyigl ip toyrfe t vothe feni xtci oathunes se pc oaronf bdthlaeilsm ( bO aucgto uwbalealrsy 2ien0xc0ao5cr)er,er bSctao.tneyd Bit.M[31G] produced a Van Zant The European Space Agency's CryoSat-1 satellite was lost in a launch failure in 2005 due to a missing mTh4ue sE iRcl euCcstDsri cat nhp aoSt wpeamecrpe t lrRoayneesdmea iarsc schioo Ipnnys tpitruottee'cs tPiohno sbcohse 1m (eP thhoabt ocso vperortglyra imns)t adleleadct iav raoteodtk iitts oantt iatundye W thirnudsotewrss aPnCd Medical [8] Videshou tdgoatcwhom5anut Alcwdiod nanmmsog mi unlosaiensdtdgr a etiotrni o pptnhrloaeyp f eliirtg.l yhT toh creioeirnn titrn oittels n ssyto swltaearm sa troraf h yiitsds oeR rt ohckeoo mcto mcpauyrnr piiecrroa rteo cwtkioiettnh.