Shape analysis (program analysis)

In program analysis, shape analysis is a static code analysis technique that discovers and verifies properties of linked, dynamically allocated data structures in (usually imperative) computer programs. It is typically used at compile time to find software bugs or to verify high-level correctness properties of programs. In Java programs, it can be used to ensure that a sort method correctly sorts a list. For C programs, it might look for places where a block of memory is not properly freed.

Applications

Shape analysis has been applied to a variety of problems:

Example

Shape analysis is a form of pointer analysis, although it is more precise than typical pointer analysis. Pointer analysis attempts to determine the set of objects to which a pointer can point (called the points-to set of the pointer). Unfortunately, these analysis are necessarily approximate (since a perfectly precise static analysis could solve the halting problem). Shape analysis can determine smaller (more precise) points-to sets.

Consider the following simple C++ program.

Item *items[10];
for (int i = 0; i < 10; ++i) {
    items[i] = new Item(...); // line [1]
}
process_items(items); // line [2]
for (int i = 0; i < 10; ++i) {
    delete items[i]; // line [3]
}

This program builds an array of objects, processes them in some arbitrary way, and then deletes them. Assuming that the process_items function is free of errors, it is clear that the program is safe: it never references freed memory, and it deletes all the objects that it has constructed.

Unfortunately, most pointer analyses have difficulty analyzing this program precisely. In order to determine points-to sets, a pointer analysis must be able to name a program's objects. In general, programs can allocate an unbounded number of objects; but in order to terminate, a pointer analysis can only use a finite set of names. A typical approximation is to give all the objects allocated on a given line of the program the same name. In the example above, all the objects constructed at line [1] would have the same name. Therefore, when the delete statement is analyzed for the first time, the analysis determines that one of the objects named [1] is being deleted. The second time the statement is analyzed (since it is in a loop) the analysis warns of a possible error: since it is unable to distinguish the objects in the array, it may be that the second delete is deleting the same object as the first delete. This warning is spurious, and the goal of shape analysis is to avoid such warnings.

Summarization and materialization

Shape analysis overcomes the problems of pointer analysis by using a more flexible naming system for objects. Rather than giving an object the same name throughout a program, objects can change names depending on the program's actions. Sometimes, several distinct objects with different names may be summarized, or merged, so that they have the same name. Then, when a summarized object is about to be used by the program, it can be materialized—that is, the summarized object is split into two objects with distinct names, one representing a single object and the other representing the remaining summarized objects. The basic heuristic of shape analysis is that objects that are being used by the program are represented using unique materialized objects, while objects not in use are summarized.

The array of objects in the example above is summarized in separate ways at lines [1], [2], and [3]. At line [1], the array has been only partly constructed. The array elements 0..i-1 contain constructed objects. The array element i is about to be constructed, and the following elements are uninitialized. Shape analysis can approximate this situation using a summary for the first set of elements, a materialized memory location for element i, and a summary for the remaining uninitialized locations, as follows:

0 .. i-1 i i+1 .. 9
pointer to constructed object (summary) uninitialized uninitialized (summary)

After the loop terminates, at line [2], there is no need to keep anything materialized. The shape analysis determines at this point that all the array elements have been initialized:

0 .. 9
pointer to constructed object (summary)

At line [3], however, the array element i is in use again. Therefore, the analysis splits the array into three segments as in line [1]. This time, though, the first segment before i has been deleted, and the remaining elements are still valid (assuming the delete statement hasn't executed yet).

0 .. i-1 i i+1 .. 9
free (summary) pointer to constructed object pointer to constructed object (summary)

Notice that in this case, the analysis recognizes that the pointer at index i has not been deleted yet. Therefore, it doesn't warn of a double deletion.

See also

References

  1. ^ Rinetzky, Noam; Sagiv, Mooly (2001). "Interprocedural Shape Analysis for Recursive Programs" (PDF). Compiler Construction. Lecture Notes in Computer Science. Vol. 2027. pp. 133–149. doi:10.1007/3-540-45306-7_10. ISBN 978-3-540-41861-0.
  2. ^ a b Berdine, Josh; Calcagno, Cristiano; Cook, Byron; Distefano, Dino; o'Hearn, Peter W.; Wies, Thomas; Yang, Hongseok (2007). "Shape Analysis for Composite Data Structures" (PDF). Computer Aided Verification. Lecture Notes in Computer Science. Vol. 4590. pp. 178–192. doi:10.1007/978-3-540-73368-3_22. ISBN 978-3-540-73367-6.

Bibliography

  • Wilhelm, Reinhard; Sagiv, Mooly; Reps, Thomas (2007). "Chapter 12: Shape Analysis and Applications". In Srikant, Y. N.; Shankar, Priti (eds.). The Compiler Design Handbook: Optimizations and Machine Code Generation, Second Edition. CRC Press. pp. 12–1–12–44. ISBN 978-1-4200-4382-2.

Read other articles:

Flat-bottomed watercraft for transport of bulk goods For other uses, see Barge (disambiguation). Barges towed by a tugboat on the River Thames in London, England, UK A British Airways Concorde being towed in New York City, USA. It is on a deck barge[1]. Barge often refers to a flat-bottomed inland waterway vessel which does not have its own means of mechanical propulsion.[2] The first modern barges were pulled by tugs, but on inland waterways, most are pushed by pusher boats, ...

 

This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: Focke-Wulf Volksjäger – news · newspapers · books · scholar · JSTOR (September 2022) (Learn how and when to remove this template message) Focke-Wulf Volksjäger Fw Volksjäger 2 Role InterceptorType of aircraft Manufacturer Focke-Wulf Status Terminated by end ...

 

A extensão dos Trapps Siberianos. (Legendas em alemão) Trapps siberianos (em russo: Сибирские траппы, Sibirskije trappy) ou províncias magmáticas siberianas estão numa formação geológica de rocha vulcânica ou grande região ígnea (sigla em inglês LIP de large igneous province), no território russo da Sibéria. Um grande evento vulcânico teria formado os trapps, sendo esse em específico tido como um dos maiores já acontecidos nos últimos 500 milhões de anos da i...

ديب واتر هورايزنDeepwater Horizonمعلومات عامةالصنف الفني دراماالموضوع انفجار ديب واتر هورايزن تاريخ الصدور 30 سبتمبر 2016مدة العرض 107 دقيقة[1]اللغة الأصلية الإنجليزيةمأخوذ عن ديب واتر هورايزنز فاينل أوارزتأليف: ديفيد بارستو، ديفيد رود، ستيفاني سولالبلد الولايات المتحدةموقع ا...

 

2008 concert tour by Girls Aloud Tangled Up TourTour by Girls AloudCover of the tour programmeAssociated albumTangled UpStart date3 May 2008End date29 August 2008Legs2No. of shows35Girls Aloud concert chronology The Greatest Hits Tour(2007) Tangled Up Tour(2008) Out of Control Tour(2009) The Tangled Up Tour was the fourth concert tour by English-Irish girl group Girls Aloud. It supported their fourth studio album Tangled Up. Tour dates were announced in November 2007. Girls Aloud performed tw...

 

CSTF3 التراكيب المتوفرة بنك بيانات البروتينOrtholog search: PDBe RCSB قائمة رموز معرفات بنك بيانات البروتين 2OND, 2OOE المعرفات الأسماء المستعارة CSTF3, CSTF-77, cleavage stimulation factor subunit 3 معرفات خارجية الوراثة المندلية البشرية عبر الإنترنت 600367 MGI: MGI:1351825 HomoloGene: 1014 GeneCards: 1479 علم الوجود الجيني الوظيفة الج...

سام عمار معلومات شخصية الميلاد سنة 1952 (العمر 70–71 سنة)  محافظة طرطوس  مواطنة الجمهورية السورية الأولى (1952–1958) الجمهورية العربية المتحدة (1958–1961) سوريا (1961–)  عضو في اتحاد الكتاب العرب  عدد الأولاد 4 [1]  الحياة العملية المدرسة الأم جامعة دمشق (الشهادة:بكالور...

 

For the 2009 film, see Shadows in the Sun (2009 film).  TV series or program Shadows in the SunWritten byBrad MirmanDirected byBrad MirmanStarringHarvey KeitelJoshua JacksonClaire ForlaniGiancarlo GianniniTheme music composerMark ThomasCountry of originItaly, UK, FranceOriginal languageEnglishProductionCinematographyMaurizio CalvesiEditorEddie HamiltonRunning time100 minutesOriginal releaseRelease November 13, 2005 (2005-11-13) (United States) Shadows in the Sun is a t...

 

Artikel ini sebatang kara, artinya tidak ada artikel lain yang memiliki pranala balik ke halaman ini.Bantulah menambah pranala ke artikel ini dari artikel yang berhubungan atau coba peralatan pencari pranala.Tag ini diberikan pada Maret 2016. Taman Nasional Ben En terletak di Thanh Hoa, Vietnam. Taman Nasional dengan luas 16.634 hektare ini ditetapkan melalui Surat Keputusan Menteri Kehutanan Nomor 33/QD-TTg/1992. Di Pulau Siberut tercatat antara lain 1389 spesies tumbuhan berkayu, 66 spesies...

RamaAwatara Wisnu sebagai putra Dasarata, pembunuh RahwanaEjaan DewanagariरामEjaan IASTRāmaNama lainRamacandra; Ragawa; Rama Wijaya; Ramabhadra; Bhatara RamaGolonganAwatara WisnuSenjataBusurWahanaGajahPasanganSintaMantraJai Shri Ramlbs Dalam agama Hindu, Rama (Sanskerta: राम; Rāma) atau Ramacandra (Sanskerta: रामचन्द्र; Rāmacandra) adalah seorang raja legendaris yang terkenal dari India yang konon hidup pada zaman Tretayuga, keturunan Dinasti Surya atau Suryaw...

 

Independent day school in Chevy Chase, MD, US Oneness-Family SchoolLocation6701 Wisconsin Avenue Chevy Chase, Maryland United StatesInformationTypeIndependentEstablishedMay 18, 1988; 35 years ago (1988-05-18)Head of schoolAndrew KuttGradesPreschool through 12Enrollment146Average class size17Student to teacher ratio1:12Websitewww.onenessfamily.org Oneness-Family School is an independent, coeducational day school whose lower-school campus is in Chevy Chase, Maryland, and its u...

 

The Dean of King's College London is responsible for overseeing the spiritual development and welfare of all students and staff of the University. The Dean's Office is the first point of contact for any queries about religious provision at King's. King's College is unusual among British universities in having an office of Dean. This is held by a priest of the Church of England, responsible for overseeing the spiritual development and welfare of all students and staff, as well as fostering voc...

Season of television series CastleSeason 6DVD coverStarring Nathan Fillion Stana Katic Jon Huertas Seamus Dever Tamala Jones Molly C. Quinn Susan Sullivan Penny Johnson Jerald Country of originUnited StatesNo. of episodes23ReleaseOriginal networkABCOriginal releaseSeptember 23, 2013 (2013-09-23) –May 12, 2014 (2014-05-12)Season chronology← PreviousSeason 5Next →Season 7List of episodes The sixth season of American crime-comedy-drama television series Castle, was...

 

Football league seasonTunisian Ligue Professionnelle 1Season2023–24Dates19 August 2023 – 2024[1]Matches played64Goals scored138 (2.16 per match)Top goalscorerBoubacar Traoré (10 goals)Biggest home winStade Tunisien 3–0 Olympique Béja(30 August 2023)Club Sfaxien 3–0 Union de Tataouine(2 September 2023)Étoile du Sahel 3–0 Avenir de Soliman(22 October 2023)Club Sfaxien 3–0 Avenir de Marsa(5 November 2023)Biggest away winEl Gawafel de Gafsa 0–3 Étoile du Sahel(3 Sep...

 

American actress (1971–2015) Amanda PetersonBornPhyllis Amanda Peterson(1971-07-08)July 8, 1971Greeley, Colorado, U.S.DiedJuly 3, 2015(2015-07-03) (aged 43)Greeley, Colorado, U.S.Other namesMandy PetersonAlma materMiddlebury CollegeUniversity of Northern ColoradoColorado State UniversityOccupationActressYears active1979–1994Known forCan't Buy Me LoveSpouses Joseph Robert Skutvik David Hartley Children2 Phyllis Amanda Peterson (July 8, 1971 – July 3, 2015...

Romanticized depiction of Quebec City in 1720 The history of Quebec City extends back thousands of years, with its first inhabitants being the First Nations peoples of the region. The arrival of French explorers in the 16th century eventually led to the establishment of Quebec City, in present-day Quebec, Canada. The city is one of the oldest European settlements in North America, with the establishment of a permanent trading post in 1608. French rule Jacques Cartier's meeting with the indige...

 

Spear Bambu runcing A bambu runcing as used by some Indonesian revolutionaries. Held at the Monumen Jogja Kembali.TypeSpearPlace of originJava, IndonesiaService historyUsed byJavaneseWarsIndonesian National RevolutionSpecificationsLength2 m (6 ft 7 in) approximatelyHilt typeBamboo A bambu runcing or prìng lancìp (which literally means Spiked Bamboo) is a traditional spear made of a sharpened bamboo. History During the Majapahit kingdom in the 15th century,...

 

Coordenadas: 44° 10' 30 N 4° 06' 36 E Saint-Julien-les-Rosiers   Comuna francesa    Símbolos Brasão de armas Localização Saint-Julien-les-RosiersLocalização de Saint-Julien-les-Rosiers na França Coordenadas 44° 10' 30 N 4° 06' 36 E País  França Região Occitânia Departamento Gard Características geográficas Área total 14,01 km² População total (2018) [1] 3 428 hab. Densidade 244,7 hab./km² Códig...

For the stable in All Japan Pro Wrestling, see Evolution (AJPW). For WWE's 2018 pay-per-view, see WWE Evolution. Professional wrestling stable Professional wrestling stable EvolutionOfficial Evolution logoStableMembersTriple H (leader) Ric FlairBatistaRandy OrtonName(s)EvolutionCombinedbilled weight1,027 lb (466 kg)DebutJanuary 20, 2003DisbandedOctober 3, 2005Years active2003–2005200720142018 (non-wrestling reunion) Evolution was an American villainous professional wrestling stabl...

 

ボーイング > マクドネル・ダグラス この記事は検証可能な参考文献や出典が全く示されていないか、不十分です。出典を追加して記事の信頼性向上にご協力ください。(このテンプレートの使い方)出典検索?: マクドネル・ダグラス – ニュース · 書籍 · スカラー · CiNii · J-STAGE · NDL · dlib.jp · ジャパンサーチ · TWL(2021...

 

Strategi Solo vs Squad di Free Fire: Cara Menang Mudah!