Conditional Must Not Aliasing for Static Race Detection Mayur Naik Alex Aiken Stanford University.

Slides:



Advertisements
Similar presentations
Dataflow Analysis for Datarace-Free Programs (ESOP 11) Arnab De Joint work with Deepak DSouza and Rupesh Nasre Indian Institute of Science, Bangalore.
Advertisements

Effective Static Deadlock Detection
1 Chao Wang, Yu Yang*, Aarti Gupta, and Ganesh Gopalakrishnan* NEC Laboratories America, Princeton, NJ * University of Utah, Salt Lake City, UT Dynamic.
Compilation 2011 Static Analysis Johnni Winther Michael I. Schwartzbach Aarhus University.
Precision Timed Embedded Systems Using TickPAD Memory Matthew M Y Kuo* Partha S Roop* Sidharta Andalam † Nitish Patel* *University of Auckland, New Zealand.
Goldilocks: Efficiently Computing the Happens-Before Relation Using Locksets Tayfun Elmas 1, Shaz Qadeer 2, Serdar Tasiran 1 1 Koç University, İstanbul,
Race Directed Random Testing of Concurrent Programs KOUSHIK SEN - UNIVERSITY OF CALIFORNIA, BERKELEY PRESENTED BY – ARTHUR KIYANOVSKI – TECHNION, ISRAEL.
A Randomized Dynamic Program Analysis for Detecting Real Deadlocks Koushik Sen CS 265.
Scalable and Precise Dynamic Datarace Detection for Structured Parallelism Raghavan RamanJisheng ZhaoVivek Sarkar Rice University June 13, 2012 Martin.
Chair of Software Engineering From Program slicing to Abstract Interpretation Dr. Manuel Oriol.
Chair of Software Engineering The alias calculus Bertrand Meyer ITMO Software Engineering Seminar June 2011.
Enforcing Sequential Consistency in SPMD Programs with Arrays Wei Chen Arvind Krishnamurthy Katherine Yelick.
Iterative Context Bounding for Systematic Testing of Multithreaded Programs Madan Musuvathi Shaz Qadeer Microsoft Research.
Scaling Model Checking of Dataraces Using Dynamic Information Ohad Shacham Tel Aviv University IBM Haifa Lab Mooly Sagiv Tel Aviv University Assaf Schuster.
The Software Model Checker BLAST by Dirk Beyer, Thomas A. Henzinger, Ranjit Jhala and Rupak Majumdar Presented by Yunho Kim Provable Software Lab, KAIST.
Static Data Race detection for Concurrent Programs with Asynchronous Calls Presenter: M. Amin Alipour Software Design Laboratory
Checking and Inferring Local Non-Aliasing Alex AikenJeffrey S. Foster UC BerkeleyUMD College Park John KodumalTachio Terauchi UC Berkeley.
Thread-modular Abstraction Refinement Tom Henzinger Ranjit Jhala Rupak Majumdar Shaz Qadeer.
ADVERSARIAL MEMORY FOR DETECTING DESTRUCTIVE RACES Cormac Flanagan & Stephen Freund UC Santa Cruz Williams College PLDI 2010 Slides by Michelle Goodstein.
Cormac Flanagan and Stephen Freund PLDI 2009 Slides by Michelle Goodstein 07/26/10.
Synthesis of Embedded Software Using Free-Choice Petri Nets.
Static Analysis of Embedded C Code John Regehr University of Utah Joint work with Nathan Cooprider.
Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.
Thread-modular Abstraction Refinement Tom Henzinger Ranjit Jhala Rupak Majumdar [UC Berkeley] Shaz Qadeer [Microsoft Research]
Next Section: Pointer Analysis Outline: –What is pointer analysis –Intraprocedural pointer analysis –Interprocedural pointer analysis (Wilson & Lam) –Unification.
Mayur Naik Alex Aiken John Whaley Stanford University Effective Static Race Detection for Java.
Range Analysis. Intraprocedural Points-to Analysis Want to compute may-points-to information Lattice:
1 RELAY: Static Race Detection on Millions of Lines of Code Jan Voung, Ranjit Jhala, and Sorin Lerner UC San Diego speaker.
Comparison Caller precisionCallee precisionCode bloat Inlining context-insensitive interproc Context sensitive interproc Specialization.
Cormac Flanagan UC Santa Cruz Velodrome: A Sound and Complete Dynamic Atomicity Checker for Multithreaded Programs Jaeheon Yi UC Santa Cruz Stephen Freund.
Pointer analysis. Pointer Analysis Outline: –What is pointer analysis –Intraprocedural pointer analysis –Interprocedural pointer analysis Andersen and.
/ PSWLAB Eraser: A Dynamic Data Race Detector for Multithreaded Programs By Stefan Savage et al 5 th Mar 2008 presented by Hong,Shin Eraser:
Thread-modular Abstraction Refinement Thomas A. Henzinger, et al. CAV 2003 Seonggun Kim KAIST CS750b.
Rahul Sharma (Stanford) Michael Bauer (NVIDIA Research) Alex Aiken (Stanford) Verification of Producer-Consumer Synchronization in GPU Programs June 15,
1 Thread Synchronization: Too Much Milk. 2 Implementing Critical Sections in Software Hard The following example will demonstrate the difficulty of providing.
15-740/ Oct. 17, 2012 Stefan Muller.  Problem: Software is buggy!  More specific problem: Want to make sure software doesn’t have bad property.
Accelerating Precise Race Detection Using Commercially-Available Hardware Transactional Memory Support Serdar Tasiran Koc University, Istanbul, Turkey.
1 Effective Static Race Detection for Java Mayur, Alex, CS Department Stanford University Presented by Roy Ganor 14/2/08 Point-To Analysis Seminar.
Deadlock Detection Nov 26, 2012 CS 8803 FPL 1. Part I Static Deadlock Detection Reference: Effective Static Deadlock Detection [ICSE’09]
A GPU Implementation of Inclusion-based Points-to Analysis Mario Méndez-Lojo (AMD) Martin Burtscher (Texas State University, USA) Keshav Pingali (U.T.
Yang Liu, Jun Sun and Jin Song Dong School of Computing National University of Singapore.
Inferring Specifications to Detect Errors in Code Mana Taghdiri Presented by: Robert Seater MIT Computer Science & AI Lab.
Pallavi Joshi* Mayur Naik † Koushik Sen* David Gay ‡ *UC Berkeley † Intel Labs Berkeley ‡ Google Inc.
Type Systems CS Definitions Program analysis Discovering facts about programs. Dynamic analysis Program analysis by using program executions.
1 Evaluating the Impact of Thread Escape Analysis on Memory Consistency Optimizations Chi-Leung Wong, Zehra Sura, Xing Fang, Kyungwoo Lee, Samuel P. Midkiff,
Pointer Analysis Lecture 2 G. Ramalingam Microsoft Research, India.
Games Development 2 Concurrent Programming CO3301 Week 9.
Aritra Sengupta, Swarnendu Biswas, Minjia Zhang, Michael D. Bond and Milind Kulkarni ASPLOS 2015, ISTANBUL, TURKEY Hybrid Static-Dynamic Analysis for Statically.
Adaptive Multi-Threading for Dynamic Workloads in Embedded Multiprocessors 林鼎原 Department of Electrical Engineering National Cheng Kung University Tainan,
Dataflow Analysis for Concurrent Programs using Datarace Detection Ravi Chugh, Jan W. Voung, Ranjit Jhala, Sorin Lerner LBA Reading Group Michelle Goodstein.
Pointer Analysis Survey. Rupesh Nasre. Aug 24, 2007.
Pointer Analysis for Multithreaded Programs Radu Rugina and Martin Rinard M I T Laboratory for Computer Science.
Concurrency Properties. Correctness In sequential programs, rerunning a program with the same input will always give the same result, so it makes sense.
Data Flow Analysis for Software Prefetching Linked Data Structures in Java Brendon Cahoon Dept. of Computer Science University of Massachusetts Amherst,
CS265: Dynamic Partial Order Reduction Koushik Sen UC Berkeley.
Random Interpretation Sumit Gulwani UC-Berkeley. 1 Program Analysis Applications in all aspects of software development, e.g. Program correctness Compiler.
Detecting Atomicity Violations via Access Interleaving Invariants
Effective Static Deadlock Detection Mayur Naik* Chang-Seo Park +, Koushik Sen +, David Gay* *Intel Research, Berkeley + UC Berkeley.
Effective Static Deadlock Detection Mayur Naik (Intel Research) Chang-Seo Park and Koushik Sen (UC Berkeley) David Gay (Intel Research)
Aritra Sengupta, Man Cao, Michael D. Bond and Milind Kulkarni PPPJ 2015, Melbourne, Florida, USA Toward Efficient Strong Memory Model Support for the Java.
1 Program Analysis Too Loopy? Set the Loops Aside Eric Larson September 25, 2011 Seattle University.
Effective Static Race Detection for Java Mayur Naik Alex Aiken Stanford University.
FastTrack: Efficient and Precise Dynamic Race Detection [FlFr09] Cormac Flanagan and Stephen N. Freund GNU OS Lab. 23-Jun-16 Ok-kyoon Ha.
Effective Data-Race Detection for the Kernel
Amir Kamil and Katherine Yelick
Concurrency Specification
Over-Approximating Boolean Programs with Unbounded Thread Creation
Yikes! Why is my SystemVerilog Testbench So Slooooow?
Pointer analysis.
Amir Kamil and Katherine Yelick
Presentation transcript:

Conditional Must Not Aliasing for Static Race Detection Mayur Naik Alex Aiken Stanford University

The Concurrency Revolution CPU clock speeds have peaked Implications for hardware –CPU vendors are shipping multi-core processors Implications for software –Concurrent programs stand to benefit the most

Debugging Concurrent Programs is Hard Concurrency bugs triggered non-deterministically –Prevalent testing techniques ineffective A race condition is a common concurrency bug –Two threads can simultaneously access a memory location –At least one access is a write

Locking for Race Freedom // Thread 1: // Thread 2: sync ( ) { ….f … ….f … } l1 e2e1 l2

MUST-NOT-ALIAS( e1, e2 ) l1 and l2 always refer to the same object e1 and e2 never refer to the same object Field f is race-free if: Proving Race Freedom: Traditional Alias Analysis // Thread 1: // Thread 2: sync ( ) { ….f … ….f … } l1 e2e1 ¬ MAY-ALIAS( e1, e2 ) l2 MUST-ALIAS( l1, l2 ) OR

Must Alias Analysis is Hard Our previous approach (PLDI’06) –performed a may alias analysis –simple approximation of a must alias analysis –effective but unsound New approach –found must alias analysis unneeded for race detection! –conditional must not alias analysis is sufficient –effective and sound

Field f is race-free if: Proving Race Freedom: Conditional Must Not Aliasing // Thread 1: // Thread 2: sync ( ) { ….f … ….f … } l1 e2e1 l2 Whenever l1 and l2 refer to different objects, e1 and e2 also refer to different objects MUST-NOT-ALIAS( l1, l2 ) => MUST-NOT-ALIAS( e1, e2 )

Example a = new h0[N]; for (i = 1; i <= N; i++) a[i] = new h1; a[i].g = new h2; … … 1 1,h1 0,h0 for (j = 1; j <= M; j++) fork { x = a[*]; sync (?) { x.g.f = 0; } } N N,h2 N,h1 g 1,h2 g … … i,h2 i i,h1 g

sync (?) { x2.g.f = 0; } Example … … 1 1,h1 … … 0,h0 N N,h2 N,h1 g 1,h2 g i,h2 i i,h1 g a = new h0[N]; for (i = 1; i <= N; i++) a[i] = new h1; a[i].g = new h2; for (j = 1; j <= M; j++) fork { x = a[*]; sync (?) { x1.g.f = 0; } }

MUST-NOT-ALIAS( l1, l2 ) => MUST-NOT-ALIAS( e1, e2 )MUST-NOT-ALIAS( a, a ) => MUST-NOT-ALIAS( x1.g, x2.g ) Field f is race-free if: true for (j = 1; j <= M; j++) fork { x = a[*]; sync (a) { x1.g.f = 0; } } sync (a) { x2.g.f = 0; } Example: Coarse-grained Locking a = new h0[N]; for (i = 1; i <= N; i++) a[i] = new h1; a[i].g = new h2; … … 1 1,h1 … … N N,h2 N,h1 g 1,h2 g i i,h1 g 0,h0 i,h2

sync (?) { x2.g.f = 0; } Example … … 1 1,h1 … … 0,h0 N N,h2 N,h1 g 1,h2 g i,h2 i i,h1 g a = new h0[N]; for (i = 1; i <= N; i++) a[i] = new h1; a[i].g = new h2; for (j = 1; j <= M; j++) fork { x = a[*]; sync (?) { x1.g.f = 0; } }

MUST-NOT-ALIAS( l1, l2 ) => MUST-NOT-ALIAS( e1, e2 )MUST-NOT-ALIAS( x1.g, x2.g ) => MUST-NOT-ALIAS( x1.g, x2.g ) true sync (x2.g) { x2.g.f = 0; } Example: Fine-grained Locking a = new h0[N]; for (i = 1; i <= N; i++) a[i] = new h1; a[i].g = new h2; for (j = 1; j <= M; j++) fork { x = a[*]; sync (x1.g) { x1.g.f = 0; } } … … 1 1,h1 … … 0,h0 N N,h2 N,h1 g 1,h2 g i i,h1 g i,h2 Field f is race-free if:

sync (?) { x2.g.f = 0; } Example … … 1 1,h1 … … 0,h0 N N,h2 N,h1 g 1,h2 g i,h2 i i,h1 g a = new h0[N]; for (i = 1; i <= N; i++) a[i] = new h1; a[i].g = new h2; for (j = 1; j <= M; j++) fork { x = a[*]; sync (?) { x1.g.f = 0; } }

MUST-NOT-ALIAS( l1, l2 ) => MUST-NOT-ALIAS( e1, e2 )MUST-NOT-ALIAS( x1, x2 ) => MUST-NOT-ALIAS( x1.g, x2.g ) true (field g of distinct h1 objects linked to distinct h2 objects) Example: Medium-grained Locking a = new h0[N]; for (i = 1; i <= N; i++) a[i] = new h1; a[i].g = new h2; for (j = 1; j <= M; j++) fork { x = a[*]; sync (x1) { x1.g.f = 0; } } sync (x2) { x2.g.f = 0; } … … 1 1,h1 … … 0,h0 N N,h2 N,h1 g 1,h2 g i,h2 i i,h1 g Field f is race-free if:

{ … h2 … } = DR({ … h1 … }) iff in every execution: –from distinct h1 objects –we can reach (via 1 or more edges) –only distinct h2 objects Disjoint Reachability Property j,h1 i ≠ j k ≠ l i,h1 k,h2 ► ► l,h2 ► ►

Example: Medium-grained Locking Is {h2} ⊆ DR({h1})? Yes! a = new h0[N]; for (i = 1; i <= N; i++) a[i] = new h1; a[i].g = new h2; … … 1,h1 … … 0,h0 N,h2 N,h1 1,h2i,h2 i,h1 ► ►► ► ► ►

Disjoint Reachability Analysis Types (a, h): –a is one of { 0, 1, ⊤ } –h is an object allocation site Effects (a1, h1) ► (a2, h2) –means left object linked to right object via some field Key property of (1, h1) ► (1, h2) –linked objects created in same loop iteration

Example: Medium-grained Locking a = new h0[N]; for (i = 1; i <= N; i++) a[i] = new h1; a[i].g = new h2; 0,h0 1,h1 1,h2 ► ► Is {h2} ⊆ DR({h1})? Yes!

// Thread 1: // Thread 2: sync (l1) { sync (l2) { … e1.f … … e2.f … } Conditional Must Not Alias Analysis using Disjoint Reachability Analysis PointsTo ( l1 ) PointsTo ( e1 ) PointsTo ( e2 ) MUST-NOT-ALIAS( l1, l2 ) => MUST-NOT-ALIAS( e1, e2 ) PointsTo ( l2 ) Field f is race-free if: –( PointsTo ( e1 ) ∩ PointsTo ( e2 )) ⊆ DR( PointsTo ( l1 ) ∪ PointsTo ( l2 )) –l1 is a prefix of e1 and l2 is a prefix of e2 ⊆ DR

–( PointsTo ( e1 ) ∩ PointsTo ( e2 )) ⊆ DR( PointsTo ( l1 ) ∪ PointsTo ( l2 )) –l1 is a prefix of e1 and l2 is a prefix of e2 –( PointsTo ( x1.g ) ∩ PointsTo ( x2.g )) ⊆ DR( PointsTo ( x1 ) ∪ PointsTo ( x2 )) –x1 is a prefix of x1.g and x2 is a prefix of x2.g Example: Medium-grained Locking a = new h0[N]; for (i = 1; i <= N; i++) a[i] = new h1; a[i].g = new h2; for (j = 1; j <= M; j++) fork { x = a[*]; sync (x1) { x1.g.f = 0; } } sync (x2) { x2.g.f = 0; } Field f is race-free if: … … N h2 g h1 h2 i g h1 h2 g 1 h1 … … h0 PointsTo ( x2 ) PointsTo ( x2.g ) PointsTo ( x1 ) PointsTo ( x1.g ) –({h2}) ⊆ DR({h1}) –x1 is a prefix of x1.g and x2 is a prefix of x2.g –true

Implementation Aspects A type is a pair (Π, h) where: –Π is a vector of { 0, 1, ⊤ } values, one per method All loops transformed to tail-recursive methods Uniformly handles loops and recursive methods –h is a k-object-sensitive object allocation site

Implementation Aspects Circular dependency between type-and-effect analysis and race freedom Fact ( z = y ) valid after line 3 only if field f is race-free: 1: x.f = y; 2:... // no writes to aliases of x.f 3: z = x.f; Race detection algorithm performs fixpoint computation –Begins assuming no races –Type-and-effect analysis kills facts as new races are found –Terminates when no more races are found

Benchmarks #classes #lines of Java code app lib app lib time philo ,5823m14s elevator ,1474m43s tsp ,0263m21s jdbm114322,190112,1394m11s jdbf254375,484121,1177m12s pool224345,531114,1215m13s jtds ,190129,01610m42s ftp ,897140,2219m21s

Experimental Results old pairs new pairs likely unlikely original pairs real false real false philo13, elevator59, tsp98, jdbm189, jdbf132, pool241, jtds398, ftp487,

Related Work Vectorizing compilers –loop vectors akin to iteration space and dependence distance Disjoint reachability –ranging from ownership types to theorem-proving approaches Race detection –Dynamic (happens-before, lockset, hybrid) –Static (type systems, dataflow analyses, model checkers) Atomicity checking –atomicity a higher-level property than race freedom –but many atomicity checkers do race detection as first step

Summary of Results Conditional Must Not Aliasing –A new aliasing property and analysis Disjoint Reachability –A new lightweight shape property and analysis A new race detection algorithm –Sound –Effective in practice

The End