SlideShare a Scribd company logo
Specifying Compatible Sharing in
Data Structures
Asankhaya Sharma, Aquinas Hobor, Wei-Ngan Chin
SourceClear & National University of Singapore
ICFEM 2015
Building Reliable Software
• Formal Verification
– Proving correctness
of programs
• Testing
– Discovering bugs
in programs
17/2/2016 ICFEM 2015 2
Automated Verification with SL
• Hoare Logic
– Specify pre and post conditions for each method
• Separation Logic
– Heap manipulating programs
– Separating conjunction “*” denotes disjoint heaps
• Using the HIP/SLEEK Verification System
17/2/2016 ICFEM 2015 3
Overview
code verifier
(HIP)
separation
logic prover
(SLEEK)
Pre/Post Predicates LemmasCode
range of pure provers …
Omega, MONA, Isabelle, Coq, SMT, Redlog, MiniSAT, Mathematica
17/2/2016 ICFEM 2015 4
An Example – List Length
struct node{
int val;
struct node* next;
};
int length(struct node* p)
{
if(p == NULL) return 0;
else return 1 + length(p->next);
}
17/2/2016 ICFEM 2015 5
List Predicate
Example of Acyclic List : list(x)
x
null
list(self)  self=null
 ∃r . self node(_,r)  list(r)
pointer to memory spatial conjunction
17/2/2016 ICFEM 2015 6
Syntactic Abbreviation (ASCII)
list(self)  self=null
 ∃ r . self node(_, r)  list(r)
list == self=null
or self::node_, r  r::list
implicit existential instantiation
17/2/2016 ICFEM 2015 7
Verify with Shape Property
struct node{
int val;
struct node* next;
};
/*@
list<> == self=null or self::node<_,q>*q::list<>;
*/
int length(struct node* p)
/*@
requires p::list<>
ensures p::list<>;
*/
{
if(p == NULL) return 0;
else return 1 + length(p->next);
}
Predicate Definition
Method Pre and
Post condition
Memory Safety
17/2/2016 ICFEM 2015 8
With Size
listn == self=null & n=0
or self::node_, r  r::listn-1
inv n >= 0
parameter on length of linked list
predicate invariant
x::ll5
x
null
17/2/2016 ICFEM 2015 9
Verify with Shape and Size
int length(struct node* p)
/*@
requires p::list<n>
ensures p::list<n> & res=n;
*/
{
if(p == NULL) return 0;
else return 1 + length(p->next);
}
Memory Safety
Length of the List
17/2/2016 ICFEM 2015 10
Frame Rule
P RP * R
Frame Rule
P {c} Q
-------------------
P * R {c} Q * R
17/2/2016 ICFEM 2015 11
From Separation to Sharing
• Disjoint Heaps (*)
– x::node<a,b> * y::node<c,d>
• Aliased Heaps (&)
– x::node<a,b> & y::node<c,d>
• Overlaid Heaps (&*)
– x::node<a,_> &* y::node<_,d>
17/2/2016 ICFEM 2015 12
Overlaid Data Structures
17/2/2016 ICFEM 2015 13
Compatible Sharing
Disk IO Scheduler
– List of Nodes (ll) and Tree of Nodes (tree)
– The linked list and tree represent multiple views
over same set of nodes
struct node{
int val;
struct node* next;
struct node* parent;
struct node* left;
struct node* right;};
17/2/2016 ICFEM 2015 14
Related Work
Oukseh Lee, Hongseok Yang and Rasmus Petersen. "Program analysis for overlaid data
structures." Computer Aided Verification. Springer Berlin Heidelberg, 2011.
Cezara Drăgoi, Constantin Enea, and Mihaela Sighireanu. "Local Shape Analysis for Overlaid Data
Structures." Static Analysis. Springer Berlin Heidelberg, 2013.
Expressivity Entailment
Procedure
Program
Analysis
Local
Reasoning
Certified
Proof
Properties
[Lee 2011] List and Tree ✗ ✓ ✗ ✗ Shape
[Drăgoi
2013]
Only Lists ✗ ✓ ✓ ✗ Shape
HIPComp User
Defined
Predicates
✓ ✗ ✓ ✓ Shape, Size
and Bag
17/2/2016 ICFEM 2015 15
Key Contributions
• Specification mechanism for arbitrary user
defined overlaid data structures
• Entailment procedure to reason about
compatible sharing with overlaid data
structures
• HIPComp Tool
– http://loris-
7.ddns.comp.nus.edu.sg/~project/HIPComp/
– Certified proof of soundness in Coq
17/2/2016 ICFEM 2015 16
LL &* Tree
ll<S> == self = null & S = {}
or self::node<_@I,p,_@A,_@A,_@A>
* p::ll<Sp> & S = Sp U {self}
tree<p,S> == self = null & S = {}
or self::node<_@I,_@A,p,lt,rt>
* lt::tree<self,Sl> * rt::tree<self,Sr>
& S = Sl U Sr U {self}
x::ll<S> &* t::tree<_,S>
Field Annotations
@A – Absent
@I – Immutable
Memory Footprint
S – Set of Addresses
17/2/2016 ICFEM 2015 17
Memory Specifications
XMem(P) = {}->()
XMem(H & P) = XMem(H)
XMem(H1 * H2) = XMem (H1) DU XMem(H2)
XMem(H1 &* H2) = XMem(H1) U XMem(H2)
…
XMem(x::node<v@I,p>) = {x}->(node<@I,@M>)
A memory specification of a
predicate is of the form
S->L
S is the set of addresses and
L is the list of field annotations
x::ll<S> &* t::tree<_,S>
XMem(x::ll<S>) =
S->(node<@I,@M,@A,@A,@A>)
XMem(t::tree<_,S>) =
S->(node<@I,@A,@M,@M,@M)
Compatible Fields
@A @M
@M @A
@I @I
@A @A
17/2/2016 ICFEM 2015 18
Compatible Frame Rule
Compatible(P,R)
Compatible(Q,R)
P {c} Q
-----------------------------------
P &* R {c} Q &* R
17/2/2016
Same memory and
compatible field
annotations
ICFEM 2015 19
void move_request(node q1s, node q2, node q1t)
requires (q1s::ll<S> &* q1t::tree<_,S>) * q2::ll<T>
ensures (q1s::ll<Su> &* q1t::tree<_,Su>) * q2::ll<Tu>
& S = Su U {q1s} & Tu = T U {q1s};
{
node c;
c = list_remove_first(q1s);
if (c == null) return;
tree_remove(c,q1t);
list_add_first(q2,c);
c = null;
}
DISK IO Scheduler Example
17/2/2016
Compatible Frame Rule
Compatible Frame Rule
Frame Rule
ICFEM 2015 20
Implementation
• Developed an entailment procedure using
memory specification and compatible sharing
• HIPComp Tool and Coq Proofs
– A prototype in Objective Caml
http://loris-
7.ddns.comp.nus.edu.sg/~project/HIPComp/
– Based on HIP/SLEEK verification system
• Benchmark of Programs with Sharing
– Examples from papers and system software
17/2/2016 ICFEM 2015 21
Coq Development
Coq File Proof Time (s) Description
PA.v 355 2.40 Syntax and Semantics of PA
SLPA.v 416 3.38 Reducing Separation Logic to PA
SLSET.v 169 7.32 Reducing Separation Logic to MONA
940 13.10 Total Coq
Certified functions XPure (SLPA.v) and XMem (SLSET.v) are required to show
the soundness of the compatible frame rule
17/2/2016 ICFEM 2015 22
Coq Development
• Found two soundness issues
– In the paper pen proof of XPure function given in
[Chin 2012] a condition was missing (p!=0) in one
of the cases
– Certifying XMem function helped uncover a
soundness bug in the implementation where the
order of Matching and Splitting rules was wrong
Chin, Wei-Ngan, et al. "Automated verification of shape, size and bag properties via
user-defined predicates in separation logic." Science of Computer Programming 77.9
(2012): 1006-1036.
17/2/2016 ICFEM 2015 23
Experiments
Program LOC
Timing
(Seconds)
Sharing (%)
Compatibility
(%)
PLL (Shape, Size) 30 0.28 100 11
Compatible Pairs 12 0.09 100 25
LL &* SortedLL (Shape, Bag) 175 0.61 22 22
LL &* Tree (Shape) 70 0.24 16 7
Process Scheduler (Shape) 70 0.47 33 23
Disk IO Scheduler (Shape) 88 1.30 16 27
Doubly Circular List (Shape) 50 0.41 50 32
17/2/2016 ICFEM 2015 24
Conclusions
• Specification Mechanism for Overlaid Data
Structures
– Entailment Procedure for Verifying Programs with
Compatible Sharing
• Future work
– Eliminate explicit Set constraints
– Unrestricted sharing
17/2/2016 ICFEM 2015 25
Thank You!
• Questions?
• Contact
– asankhaya@u.nus.edu
– Twitter
• @asankhaya
17/2/2016 ICFEM 2015 26

More Related Content

What's hot

Design and minimization of reversible programmable logic arrays and its reali...
Design and minimization of reversible programmable logic arrays and its reali...Design and minimization of reversible programmable logic arrays and its reali...
Design and minimization of reversible programmable logic arrays and its reali...
Sajib Mitra
 
Algorithm Selection for Preferred Extensions Enumeration
Algorithm Selection for Preferred Extensions EnumerationAlgorithm Selection for Preferred Extensions Enumeration
Algorithm Selection for Preferred Extensions Enumeration
Federico Cerutti
 
Argumentation Extensions Enumeration as a Constraint Satisfaction Problem: a ...
Argumentation Extensions Enumeration as a Constraint Satisfaction Problem: a ...Argumentation Extensions Enumeration as a Constraint Satisfaction Problem: a ...
Argumentation Extensions Enumeration as a Constraint Satisfaction Problem: a ...
Federico Cerutti
 
A SCC Recursive Meta-Algorithm for Computing Preferred Labellings in Abstract...
A SCC Recursive Meta-Algorithm for Computing Preferred Labellings in Abstract...A SCC Recursive Meta-Algorithm for Computing Preferred Labellings in Abstract...
A SCC Recursive Meta-Algorithm for Computing Preferred Labellings in Abstract...
Federico Cerutti
 
Complete and Interpretable Conformance Checking of Business Processes
Complete and Interpretable Conformance Checking of Business ProcessesComplete and Interpretable Conformance Checking of Business Processes
Complete and Interpretable Conformance Checking of Business Processes
Marlon Dumas
 
Cerutti -- TAFA2013
Cerutti -- TAFA2013Cerutti -- TAFA2013
Cerutti -- TAFA2013
Federico Cerutti
 
Incremental and Interactive Process Model Repair
Incremental and Interactive Process Model RepairIncremental and Interactive Process Model Repair
Incremental and Interactive Process Model Repair
Marlon Dumas
 
OmpSs – improving the scalability of OpenMP
OmpSs – improving the scalability of OpenMPOmpSs – improving the scalability of OpenMP
OmpSs – improving the scalability of OpenMP
Intel IT Center
 
Iaetsd an survey of efficient fpga implementation of advanced encryption
Iaetsd an survey of efficient fpga implementation of advanced encryptionIaetsd an survey of efficient fpga implementation of advanced encryption
Iaetsd an survey of efficient fpga implementation of advanced encryption
Iaetsd Iaetsd
 
Lisp tutorial
Lisp tutorialLisp tutorial
Lisp tutorial
Nilt1234
 

What's hot (10)

Design and minimization of reversible programmable logic arrays and its reali...
Design and minimization of reversible programmable logic arrays and its reali...Design and minimization of reversible programmable logic arrays and its reali...
Design and minimization of reversible programmable logic arrays and its reali...
 
Algorithm Selection for Preferred Extensions Enumeration
Algorithm Selection for Preferred Extensions EnumerationAlgorithm Selection for Preferred Extensions Enumeration
Algorithm Selection for Preferred Extensions Enumeration
 
Argumentation Extensions Enumeration as a Constraint Satisfaction Problem: a ...
Argumentation Extensions Enumeration as a Constraint Satisfaction Problem: a ...Argumentation Extensions Enumeration as a Constraint Satisfaction Problem: a ...
Argumentation Extensions Enumeration as a Constraint Satisfaction Problem: a ...
 
A SCC Recursive Meta-Algorithm for Computing Preferred Labellings in Abstract...
A SCC Recursive Meta-Algorithm for Computing Preferred Labellings in Abstract...A SCC Recursive Meta-Algorithm for Computing Preferred Labellings in Abstract...
A SCC Recursive Meta-Algorithm for Computing Preferred Labellings in Abstract...
 
Complete and Interpretable Conformance Checking of Business Processes
Complete and Interpretable Conformance Checking of Business ProcessesComplete and Interpretable Conformance Checking of Business Processes
Complete and Interpretable Conformance Checking of Business Processes
 
Cerutti -- TAFA2013
Cerutti -- TAFA2013Cerutti -- TAFA2013
Cerutti -- TAFA2013
 
Incremental and Interactive Process Model Repair
Incremental and Interactive Process Model RepairIncremental and Interactive Process Model Repair
Incremental and Interactive Process Model Repair
 
OmpSs – improving the scalability of OpenMP
OmpSs – improving the scalability of OpenMPOmpSs – improving the scalability of OpenMP
OmpSs – improving the scalability of OpenMP
 
Iaetsd an survey of efficient fpga implementation of advanced encryption
Iaetsd an survey of efficient fpga implementation of advanced encryptionIaetsd an survey of efficient fpga implementation of advanced encryption
Iaetsd an survey of efficient fpga implementation of advanced encryption
 
Lisp tutorial
Lisp tutorialLisp tutorial
Lisp tutorial
 

Viewers also liked

Curriculum vitae
Curriculum vitaeCurriculum vitae
Curriculum vitae
Abdelmoneim Ali
 
2 que es algebra
2 que es algebra2 que es algebra
2 que es algebra
OROREAL111
 
Watch formula 1 grand prix de monaco 2015 live
Watch formula 1 grand prix de monaco 2015 liveWatch formula 1 grand prix de monaco 2015 live
Watch formula 1 grand prix de monaco 2015 live
adelaaiah
 
Reynolds SIC 2015 FINAL
Reynolds SIC 2015 FINALReynolds SIC 2015 FINAL
Reynolds SIC 2015 FINALPaul Reynolds
 
26 jan 2014 kyk, hy kom!!!
26 jan 2014 kyk, hy kom!!!26 jan 2014 kyk, hy kom!!!
26 jan 2014 kyk, hy kom!!!Ernest Potgieter
 
Boletín Iñamo 25. Geografía Viva. Diciembre 2015
Boletín Iñamo 25. Geografía Viva. Diciembre 2015Boletín Iñamo 25. Geografía Viva. Diciembre 2015
Boletín Iñamo 25. Geografía Viva. Diciembre 2015
Nucleo Geografia Viva A.C
 
Cours Marketing Mobile - Ulrich Rozier
Cours Marketing Mobile - Ulrich RozierCours Marketing Mobile - Ulrich Rozier
Cours Marketing Mobile - Ulrich Rozier
Ulrich Rozier
 
Proiect de lectie
Proiect de lectieProiect de lectie
Proiect de lectie
razvi1994
 
Adsorption chromatography
Adsorption chromatographyAdsorption chromatography
Adsorption chromatography
cyril jose jithu
 
Я – стрела (психологическая техника с картами "1000 идей")
Я – стрела (психологическая техника с картами "1000 идей")Я – стрела (психологическая техника с картами "1000 идей")
Я – стрела (психологическая техника с картами "1000 идей")
1000 идей тренинг-центр
 

Viewers also liked (12)

Natural resources
Natural resourcesNatural resources
Natural resources
 
Curriculum vitae
Curriculum vitaeCurriculum vitae
Curriculum vitae
 
2 que es algebra
2 que es algebra2 que es algebra
2 que es algebra
 
Watch formula 1 grand prix de monaco 2015 live
Watch formula 1 grand prix de monaco 2015 liveWatch formula 1 grand prix de monaco 2015 live
Watch formula 1 grand prix de monaco 2015 live
 
Reynolds SIC 2015 FINAL
Reynolds SIC 2015 FINALReynolds SIC 2015 FINAL
Reynolds SIC 2015 FINAL
 
INX comp info
INX comp infoINX comp info
INX comp info
 
26 jan 2014 kyk, hy kom!!!
26 jan 2014 kyk, hy kom!!!26 jan 2014 kyk, hy kom!!!
26 jan 2014 kyk, hy kom!!!
 
Boletín Iñamo 25. Geografía Viva. Diciembre 2015
Boletín Iñamo 25. Geografía Viva. Diciembre 2015Boletín Iñamo 25. Geografía Viva. Diciembre 2015
Boletín Iñamo 25. Geografía Viva. Diciembre 2015
 
Cours Marketing Mobile - Ulrich Rozier
Cours Marketing Mobile - Ulrich RozierCours Marketing Mobile - Ulrich Rozier
Cours Marketing Mobile - Ulrich Rozier
 
Proiect de lectie
Proiect de lectieProiect de lectie
Proiect de lectie
 
Adsorption chromatography
Adsorption chromatographyAdsorption chromatography
Adsorption chromatography
 
Я – стрела (психологическая техника с картами "1000 идей")
Я – стрела (психологическая техника с картами "1000 идей")Я – стрела (психологическая техника с картами "1000 идей")
Я – стрела (психологическая техника с картами "1000 идей")
 

Similar to Specifying compatible sharing in data structures

Certified Reasoning for Automated Verification
Certified Reasoning for Automated VerificationCertified Reasoning for Automated Verification
Certified Reasoning for Automated Verification
Asankhaya Sharma
 
The CAOS framework: democratize the acceleration of compute intensive applica...
The CAOS framework: democratize the acceleration of compute intensive applica...The CAOS framework: democratize the acceleration of compute intensive applica...
The CAOS framework: democratize the acceleration of compute intensive applica...
NECST Lab @ Politecnico di Milano
 
Network security mannual (2)
Network security mannual (2)Network security mannual (2)
Network security mannual (2)
Vivek Kumar Sinha
 
Web Template Mechanisms in SOC Verification - DVCon.pdf
Web Template Mechanisms in SOC Verification - DVCon.pdfWeb Template Mechanisms in SOC Verification - DVCon.pdf
Web Template Mechanisms in SOC Verification - DVCon.pdf
SamHoney6
 
r,rstats,r language,r packages
r,rstats,r language,r packagesr,rstats,r language,r packages
r,rstats,r language,r packagesAjay Ohri
 
design-compiler.pdf
design-compiler.pdfdesign-compiler.pdf
design-compiler.pdf
FrangoCamila
 
Environment Canada's Data Management Service
Environment Canada's Data Management ServiceEnvironment Canada's Data Management Service
Environment Canada's Data Management Service
Safe Software
 
[Webinar Slides] Programming the Network Dataplane in P4
[Webinar Slides] Programming the Network Dataplane in P4[Webinar Slides] Programming the Network Dataplane in P4
[Webinar Slides] Programming the Network Dataplane in P4
Open Networking Summits
 
Performance Troubleshooting Using Apache Spark Metrics
Performance Troubleshooting Using Apache Spark MetricsPerformance Troubleshooting Using Apache Spark Metrics
Performance Troubleshooting Using Apache Spark Metrics
Databricks
 
f37-book-intarch-pres-pt2.ppt
f37-book-intarch-pres-pt2.pptf37-book-intarch-pres-pt2.ppt
f37-book-intarch-pres-pt2.ppt
ssuserf06014
 
f37-book-intarch-pres-pt2.ppt
f37-book-intarch-pres-pt2.pptf37-book-intarch-pres-pt2.ppt
f37-book-intarch-pres-pt2.ppt
Vhhvf
 
Open Source Systems Performance
Open Source Systems PerformanceOpen Source Systems Performance
Open Source Systems Performance
Brendan Gregg
 
Sparklyr: Big Data enabler for R users
Sparklyr: Big Data enabler for R usersSparklyr: Big Data enabler for R users
Sparklyr: Big Data enabler for R users
ICTeam S.p.A.
 
Sparklyr: Big Data enabler for R users - Serena Signorelli, ICTEAM
Sparklyr: Big Data enabler for R users - Serena Signorelli, ICTEAMSparklyr: Big Data enabler for R users - Serena Signorelli, ICTEAM
Sparklyr: Big Data enabler for R users - Serena Signorelli, ICTEAM
Data Science Milan
 
GTC16 - S6410 - Comparing OpenACC 2.5 and OpenMP 4.5
GTC16 - S6410 - Comparing OpenACC 2.5 and OpenMP 4.5GTC16 - S6410 - Comparing OpenACC 2.5 and OpenMP 4.5
GTC16 - S6410 - Comparing OpenACC 2.5 and OpenMP 4.5
Jeff Larkin
 
RAMSES: Robust Analytic Models for Science at Extreme Scales
RAMSES: Robust Analytic Models for Science at Extreme ScalesRAMSES: Robust Analytic Models for Science at Extreme Scales
RAMSES: Robust Analytic Models for Science at Extreme Scales
Ian Foster
 
MeCC: Memory Comparison-based Code Clone Detector
MeCC: Memory Comparison-based Code Clone DetectorMeCC: Memory Comparison-based Code Clone Detector
MeCC: Memory Comparison-based Code Clone Detector
영범 정
 
MeCC: Memory Comparison based Clone Detector
MeCC: Memory Comparison based Clone DetectorMeCC: Memory Comparison based Clone Detector
MeCC: Memory Comparison based Clone Detector
Sung Kim
 
Compiler lec 2
Compiler lec 2Compiler lec 2
Compiler lec 2
Ramadan Babers, PhD
 

Similar to Specifying compatible sharing in data structures (20)

Certified Reasoning for Automated Verification
Certified Reasoning for Automated VerificationCertified Reasoning for Automated Verification
Certified Reasoning for Automated Verification
 
The CAOS framework: democratize the acceleration of compute intensive applica...
The CAOS framework: democratize the acceleration of compute intensive applica...The CAOS framework: democratize the acceleration of compute intensive applica...
The CAOS framework: democratize the acceleration of compute intensive applica...
 
Network security mannual (2)
Network security mannual (2)Network security mannual (2)
Network security mannual (2)
 
Web Template Mechanisms in SOC Verification - DVCon.pdf
Web Template Mechanisms in SOC Verification - DVCon.pdfWeb Template Mechanisms in SOC Verification - DVCon.pdf
Web Template Mechanisms in SOC Verification - DVCon.pdf
 
BIRTE-13-Kawashima
BIRTE-13-KawashimaBIRTE-13-Kawashima
BIRTE-13-Kawashima
 
r,rstats,r language,r packages
r,rstats,r language,r packagesr,rstats,r language,r packages
r,rstats,r language,r packages
 
design-compiler.pdf
design-compiler.pdfdesign-compiler.pdf
design-compiler.pdf
 
Environment Canada's Data Management Service
Environment Canada's Data Management ServiceEnvironment Canada's Data Management Service
Environment Canada's Data Management Service
 
[Webinar Slides] Programming the Network Dataplane in P4
[Webinar Slides] Programming the Network Dataplane in P4[Webinar Slides] Programming the Network Dataplane in P4
[Webinar Slides] Programming the Network Dataplane in P4
 
Performance Troubleshooting Using Apache Spark Metrics
Performance Troubleshooting Using Apache Spark MetricsPerformance Troubleshooting Using Apache Spark Metrics
Performance Troubleshooting Using Apache Spark Metrics
 
f37-book-intarch-pres-pt2.ppt
f37-book-intarch-pres-pt2.pptf37-book-intarch-pres-pt2.ppt
f37-book-intarch-pres-pt2.ppt
 
f37-book-intarch-pres-pt2.ppt
f37-book-intarch-pres-pt2.pptf37-book-intarch-pres-pt2.ppt
f37-book-intarch-pres-pt2.ppt
 
Open Source Systems Performance
Open Source Systems PerformanceOpen Source Systems Performance
Open Source Systems Performance
 
Sparklyr: Big Data enabler for R users
Sparklyr: Big Data enabler for R usersSparklyr: Big Data enabler for R users
Sparklyr: Big Data enabler for R users
 
Sparklyr: Big Data enabler for R users - Serena Signorelli, ICTEAM
Sparklyr: Big Data enabler for R users - Serena Signorelli, ICTEAMSparklyr: Big Data enabler for R users - Serena Signorelli, ICTEAM
Sparklyr: Big Data enabler for R users - Serena Signorelli, ICTEAM
 
GTC16 - S6410 - Comparing OpenACC 2.5 and OpenMP 4.5
GTC16 - S6410 - Comparing OpenACC 2.5 and OpenMP 4.5GTC16 - S6410 - Comparing OpenACC 2.5 and OpenMP 4.5
GTC16 - S6410 - Comparing OpenACC 2.5 and OpenMP 4.5
 
RAMSES: Robust Analytic Models for Science at Extreme Scales
RAMSES: Robust Analytic Models for Science at Extreme ScalesRAMSES: Robust Analytic Models for Science at Extreme Scales
RAMSES: Robust Analytic Models for Science at Extreme Scales
 
MeCC: Memory Comparison-based Code Clone Detector
MeCC: Memory Comparison-based Code Clone DetectorMeCC: Memory Comparison-based Code Clone Detector
MeCC: Memory Comparison-based Code Clone Detector
 
MeCC: Memory Comparison based Clone Detector
MeCC: Memory Comparison based Clone DetectorMeCC: Memory Comparison based Clone Detector
MeCC: Memory Comparison based Clone Detector
 
Compiler lec 2
Compiler lec 2Compiler lec 2
Compiler lec 2
 

More from Asankhaya Sharma

9 types of people you find on your team
9 types of people you find on your team9 types of people you find on your team
9 types of people you find on your team
Asankhaya Sharma
 
Design and Implementation of the Security Graph Language
Design and Implementation of the Security Graph LanguageDesign and Implementation of the Security Graph Language
Design and Implementation of the Security Graph Language
Asankhaya Sharma
 
Securing Open Source Code in Enterprise
Securing Open Source Code in EnterpriseSecuring Open Source Code in Enterprise
Securing Open Source Code in Enterprise
Asankhaya Sharma
 
Secure Software Development
Secure Software DevelopmentSecure Software Development
Secure Software Development
Asankhaya Sharma
 
Verified Subtyping with Traits and Mixins
Verified Subtyping with Traits and MixinsVerified Subtyping with Traits and Mixins
Verified Subtyping with Traits and Mixins
Asankhaya Sharma
 
Exploiting undefined behaviors for efficient symbolic execution
Exploiting undefined behaviors for efficient symbolic executionExploiting undefined behaviors for efficient symbolic execution
Exploiting undefined behaviors for efficient symbolic execution
Asankhaya Sharma
 
DIDAR: Database Intrusion Detection with Automated Recovery
DIDAR: Database Intrusion Detection with Automated RecoveryDIDAR: Database Intrusion Detection with Automated Recovery
DIDAR: Database Intrusion Detection with Automated Recovery
Asankhaya Sharma
 
Developer-focused Software Security
Developer-focused Software SecurityDeveloper-focused Software Security
Developer-focused Software Security
Asankhaya Sharma
 
Visualizing Symbolic Execution with Bokeh
Visualizing Symbolic Execution with BokehVisualizing Symbolic Execution with Bokeh
Visualizing Symbolic Execution with Bokeh
Asankhaya Sharma
 
Crafting a Successful Engineering Career
Crafting a Successful Engineering CareerCrafting a Successful Engineering Career
Crafting a Successful Engineering Career
Asankhaya Sharma
 
Last Days of Academy
Last Days of AcademyLast Days of Academy
Last Days of Academy
Asankhaya Sharma
 
SayCheese Ad
SayCheese AdSayCheese Ad
SayCheese Ad
Asankhaya Sharma
 

More from Asankhaya Sharma (12)

9 types of people you find on your team
9 types of people you find on your team9 types of people you find on your team
9 types of people you find on your team
 
Design and Implementation of the Security Graph Language
Design and Implementation of the Security Graph LanguageDesign and Implementation of the Security Graph Language
Design and Implementation of the Security Graph Language
 
Securing Open Source Code in Enterprise
Securing Open Source Code in EnterpriseSecuring Open Source Code in Enterprise
Securing Open Source Code in Enterprise
 
Secure Software Development
Secure Software DevelopmentSecure Software Development
Secure Software Development
 
Verified Subtyping with Traits and Mixins
Verified Subtyping with Traits and MixinsVerified Subtyping with Traits and Mixins
Verified Subtyping with Traits and Mixins
 
Exploiting undefined behaviors for efficient symbolic execution
Exploiting undefined behaviors for efficient symbolic executionExploiting undefined behaviors for efficient symbolic execution
Exploiting undefined behaviors for efficient symbolic execution
 
DIDAR: Database Intrusion Detection with Automated Recovery
DIDAR: Database Intrusion Detection with Automated RecoveryDIDAR: Database Intrusion Detection with Automated Recovery
DIDAR: Database Intrusion Detection with Automated Recovery
 
Developer-focused Software Security
Developer-focused Software SecurityDeveloper-focused Software Security
Developer-focused Software Security
 
Visualizing Symbolic Execution with Bokeh
Visualizing Symbolic Execution with BokehVisualizing Symbolic Execution with Bokeh
Visualizing Symbolic Execution with Bokeh
 
Crafting a Successful Engineering Career
Crafting a Successful Engineering CareerCrafting a Successful Engineering Career
Crafting a Successful Engineering Career
 
Last Days of Academy
Last Days of AcademyLast Days of Academy
Last Days of Academy
 
SayCheese Ad
SayCheese AdSayCheese Ad
SayCheese Ad
 

Recently uploaded

RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
Alex Pruden
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Vladimir Iglovikov, Ph.D.
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 

Recently uploaded (20)

RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 

Specifying compatible sharing in data structures

  • 1. Specifying Compatible Sharing in Data Structures Asankhaya Sharma, Aquinas Hobor, Wei-Ngan Chin SourceClear & National University of Singapore ICFEM 2015
  • 2. Building Reliable Software • Formal Verification – Proving correctness of programs • Testing – Discovering bugs in programs 17/2/2016 ICFEM 2015 2
  • 3. Automated Verification with SL • Hoare Logic – Specify pre and post conditions for each method • Separation Logic – Heap manipulating programs – Separating conjunction “*” denotes disjoint heaps • Using the HIP/SLEEK Verification System 17/2/2016 ICFEM 2015 3
  • 4. Overview code verifier (HIP) separation logic prover (SLEEK) Pre/Post Predicates LemmasCode range of pure provers … Omega, MONA, Isabelle, Coq, SMT, Redlog, MiniSAT, Mathematica 17/2/2016 ICFEM 2015 4
  • 5. An Example – List Length struct node{ int val; struct node* next; }; int length(struct node* p) { if(p == NULL) return 0; else return 1 + length(p->next); } 17/2/2016 ICFEM 2015 5
  • 6. List Predicate Example of Acyclic List : list(x) x null list(self)  self=null  ∃r . self node(_,r)  list(r) pointer to memory spatial conjunction 17/2/2016 ICFEM 2015 6
  • 7. Syntactic Abbreviation (ASCII) list(self)  self=null  ∃ r . self node(_, r)  list(r) list == self=null or self::node_, r  r::list implicit existential instantiation 17/2/2016 ICFEM 2015 7
  • 8. Verify with Shape Property struct node{ int val; struct node* next; }; /*@ list<> == self=null or self::node<_,q>*q::list<>; */ int length(struct node* p) /*@ requires p::list<> ensures p::list<>; */ { if(p == NULL) return 0; else return 1 + length(p->next); } Predicate Definition Method Pre and Post condition Memory Safety 17/2/2016 ICFEM 2015 8
  • 9. With Size listn == self=null & n=0 or self::node_, r  r::listn-1 inv n >= 0 parameter on length of linked list predicate invariant x::ll5 x null 17/2/2016 ICFEM 2015 9
  • 10. Verify with Shape and Size int length(struct node* p) /*@ requires p::list<n> ensures p::list<n> & res=n; */ { if(p == NULL) return 0; else return 1 + length(p->next); } Memory Safety Length of the List 17/2/2016 ICFEM 2015 10
  • 11. Frame Rule P RP * R Frame Rule P {c} Q ------------------- P * R {c} Q * R 17/2/2016 ICFEM 2015 11
  • 12. From Separation to Sharing • Disjoint Heaps (*) – x::node<a,b> * y::node<c,d> • Aliased Heaps (&) – x::node<a,b> & y::node<c,d> • Overlaid Heaps (&*) – x::node<a,_> &* y::node<_,d> 17/2/2016 ICFEM 2015 12
  • 14. Compatible Sharing Disk IO Scheduler – List of Nodes (ll) and Tree of Nodes (tree) – The linked list and tree represent multiple views over same set of nodes struct node{ int val; struct node* next; struct node* parent; struct node* left; struct node* right;}; 17/2/2016 ICFEM 2015 14
  • 15. Related Work Oukseh Lee, Hongseok Yang and Rasmus Petersen. "Program analysis for overlaid data structures." Computer Aided Verification. Springer Berlin Heidelberg, 2011. Cezara Drăgoi, Constantin Enea, and Mihaela Sighireanu. "Local Shape Analysis for Overlaid Data Structures." Static Analysis. Springer Berlin Heidelberg, 2013. Expressivity Entailment Procedure Program Analysis Local Reasoning Certified Proof Properties [Lee 2011] List and Tree ✗ ✓ ✗ ✗ Shape [Drăgoi 2013] Only Lists ✗ ✓ ✓ ✗ Shape HIPComp User Defined Predicates ✓ ✗ ✓ ✓ Shape, Size and Bag 17/2/2016 ICFEM 2015 15
  • 16. Key Contributions • Specification mechanism for arbitrary user defined overlaid data structures • Entailment procedure to reason about compatible sharing with overlaid data structures • HIPComp Tool – http://loris- 7.ddns.comp.nus.edu.sg/~project/HIPComp/ – Certified proof of soundness in Coq 17/2/2016 ICFEM 2015 16
  • 17. LL &* Tree ll<S> == self = null & S = {} or self::node<_@I,p,_@A,_@A,_@A> * p::ll<Sp> & S = Sp U {self} tree<p,S> == self = null & S = {} or self::node<_@I,_@A,p,lt,rt> * lt::tree<self,Sl> * rt::tree<self,Sr> & S = Sl U Sr U {self} x::ll<S> &* t::tree<_,S> Field Annotations @A – Absent @I – Immutable Memory Footprint S – Set of Addresses 17/2/2016 ICFEM 2015 17
  • 18. Memory Specifications XMem(P) = {}->() XMem(H & P) = XMem(H) XMem(H1 * H2) = XMem (H1) DU XMem(H2) XMem(H1 &* H2) = XMem(H1) U XMem(H2) … XMem(x::node<v@I,p>) = {x}->(node<@I,@M>) A memory specification of a predicate is of the form S->L S is the set of addresses and L is the list of field annotations x::ll<S> &* t::tree<_,S> XMem(x::ll<S>) = S->(node<@I,@M,@A,@A,@A>) XMem(t::tree<_,S>) = S->(node<@I,@A,@M,@M,@M) Compatible Fields @A @M @M @A @I @I @A @A 17/2/2016 ICFEM 2015 18
  • 19. Compatible Frame Rule Compatible(P,R) Compatible(Q,R) P {c} Q ----------------------------------- P &* R {c} Q &* R 17/2/2016 Same memory and compatible field annotations ICFEM 2015 19
  • 20. void move_request(node q1s, node q2, node q1t) requires (q1s::ll<S> &* q1t::tree<_,S>) * q2::ll<T> ensures (q1s::ll<Su> &* q1t::tree<_,Su>) * q2::ll<Tu> & S = Su U {q1s} & Tu = T U {q1s}; { node c; c = list_remove_first(q1s); if (c == null) return; tree_remove(c,q1t); list_add_first(q2,c); c = null; } DISK IO Scheduler Example 17/2/2016 Compatible Frame Rule Compatible Frame Rule Frame Rule ICFEM 2015 20
  • 21. Implementation • Developed an entailment procedure using memory specification and compatible sharing • HIPComp Tool and Coq Proofs – A prototype in Objective Caml http://loris- 7.ddns.comp.nus.edu.sg/~project/HIPComp/ – Based on HIP/SLEEK verification system • Benchmark of Programs with Sharing – Examples from papers and system software 17/2/2016 ICFEM 2015 21
  • 22. Coq Development Coq File Proof Time (s) Description PA.v 355 2.40 Syntax and Semantics of PA SLPA.v 416 3.38 Reducing Separation Logic to PA SLSET.v 169 7.32 Reducing Separation Logic to MONA 940 13.10 Total Coq Certified functions XPure (SLPA.v) and XMem (SLSET.v) are required to show the soundness of the compatible frame rule 17/2/2016 ICFEM 2015 22
  • 23. Coq Development • Found two soundness issues – In the paper pen proof of XPure function given in [Chin 2012] a condition was missing (p!=0) in one of the cases – Certifying XMem function helped uncover a soundness bug in the implementation where the order of Matching and Splitting rules was wrong Chin, Wei-Ngan, et al. "Automated verification of shape, size and bag properties via user-defined predicates in separation logic." Science of Computer Programming 77.9 (2012): 1006-1036. 17/2/2016 ICFEM 2015 23
  • 24. Experiments Program LOC Timing (Seconds) Sharing (%) Compatibility (%) PLL (Shape, Size) 30 0.28 100 11 Compatible Pairs 12 0.09 100 25 LL &* SortedLL (Shape, Bag) 175 0.61 22 22 LL &* Tree (Shape) 70 0.24 16 7 Process Scheduler (Shape) 70 0.47 33 23 Disk IO Scheduler (Shape) 88 1.30 16 27 Doubly Circular List (Shape) 50 0.41 50 32 17/2/2016 ICFEM 2015 24
  • 25. Conclusions • Specification Mechanism for Overlaid Data Structures – Entailment Procedure for Verifying Programs with Compatible Sharing • Future work – Eliminate explicit Set constraints – Unrestricted sharing 17/2/2016 ICFEM 2015 25
  • 26. Thank You! • Questions? • Contact – asankhaya@u.nus.edu – Twitter • @asankhaya 17/2/2016 ICFEM 2015 26

Editor's Notes

  1. None of the free variables in R are modified in c
  2. Se-zera Si-here-nu