1 chao wang, yu yang*, aarti gupta, and ganesh gopalakrishnan* nec laboratories america, princeton,...

25
1 Chao Wang, Yu Yang*, Aarti Gupta, and Ganesh Gopalakrishnan* NEC Laboratories America, Princeton, NJ * University of Utah, Salt Lake City, UT Dynamic Model Checking with Property Driven Pruning to Detect Race Conditions

Upload: tyra-roys

Post on 14-Dec-2015

223 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 Chao Wang, Yu Yang*, Aarti Gupta, and Ganesh Gopalakrishnan* NEC Laboratories America, Princeton, NJ * University of Utah, Salt Lake City, UT Dynamic

1

Chao Wang, Yu Yang*, Aarti Gupta, and Ganesh Gopalakrishnan*

NEC Laboratories America, Princeton, NJ

* University of Utah, Salt Lake City, UT

Dynamic Model Checking with Property Driven Pruning to Detect Race Conditions

Page 2: 1 Chao Wang, Yu Yang*, Aarti Gupta, and Ganesh Gopalakrishnan* NEC Laboratories America, Princeton, NJ * University of Utah, Salt Lake City, UT Dynamic

2

Motivation

Concurrent programs are hard to debug Too many possible thread interleavings

Even for a given input

Data races – a representative type of concurrency bugs e.g., among flaws in the Therac-25 radiation therapy machine e.g., related to the 2003 North America Blackout

What’s a data race? Multiple threads can simultaneously access a shared data variable At least one is a write

Page 3: 1 Chao Wang, Yu Yang*, Aarti Gupta, and Ganesh Gopalakrishnan* NEC Laboratories America, Princeton, NJ * University of Utah, Salt Lake City, UT Dynamic

3

Related Work

Precisely detecting data races (or proving race-freedom) is hard Simultaneous reachability

Previous efforts Static checking (whole-program analysis)

[Flanagan et al 2002], [Engler & Ashcraft 2002], [Pratikakis et al 2006], [Voung et al 2007], [Kahlon et al 2007], …

Bogus warnings – too many of them!

Dynamic checking (on a particular execution trace) Eraser [Savage et. al. 1997], Valgrind [Nethercote & Seward 2003], … May miss real races; bogus warnings – may still appear

Classic model checking algorithms Full coverage, but requires model building (non-trivial) For example: pointers, rich data types, …

Page 4: 1 Chao Wang, Yu Yang*, Aarti Gupta, and Ganesh Gopalakrishnan* NEC Laboratories America, Princeton, NJ * University of Utah, Salt Lake City, UT Dynamic

4

Related Work (2)

(Stateless) dynamic model checking e.g., Verisoft (Bell labs), CHESS (MSR), Inspect (U. of Utah) Do not store the program states, but rely on a Depth-First Search to

systematically explore all feasible thread schedules

Advantages Run in the real environment no bogus warnings Full coverage for terminating programs No missed data races

Disadvantages: The search is inefficient – too many thread interleavings

Page 5: 1 Chao Wang, Yu Yang*, Aarti Gupta, and Ganesh Gopalakrishnan* NEC Laboratories America, Princeton, NJ * University of Utah, Salt Lake City, UT Dynamic

5

Related Work (3)

DPOR: Dynamic Partial Order Reduction [Flanagan & Godefroid, POPL 2005] Main idea: Remove redundant interleavings from each equivalence

class of interleavings, provided that the representative has been checked

Still not good enough! What if an entire equivalence class (of interleavings) is redundant

We need a property-specific reduction! Remove redundant interleavings within each equivalence class Remove redundant equivalence classes (w.r.t. the property)

Page 6: 1 Chao Wang, Yu Yang*, Aarti Gupta, and Ganesh Gopalakrishnan* NEC Laboratories America, Princeton, NJ * University of Utah, Salt Lake City, UT Dynamic

6

Outline

Introduction and Related Work Motivating Example Set of Locksets Modeling Unobserved Branches Experiments Conclusions

Page 7: 1 Chao Wang, Yu Yang*, Aarti Gupta, and Ganesh Gopalakrishnan* NEC Laboratories America, Princeton, NJ * University of Utah, Salt Lake City, UT Dynamic

Motivating Example

7

Error trace: b1-b7, a1-a4, a5, b8-b9, {a6,b10}

Where is the data race?Initial state: x=y=z=0

Page 8: 1 Chao Wang, Yu Yang*, Aarti Gupta, and Ganesh Gopalakrishnan* NEC Laboratories America, Princeton, NJ * University of Utah, Salt Lake City, UT Dynamic

Motivating Example

8

Traces: a1-a4,a5-a8, a9-a11,b1-b7,b8-b11 a1-a4,a5-a8, b1-b7,a9-a11,b8-b11 a1-a4,a5-a8, b1-b7,b8-b11,a9-a11 a1-a4,…………………………………. ……Error: b1-b7, a1-a4, a5, b8-b9, {a6,b10}

How would DPOR find it? … … it would take awhile.

reduction

Page 9: 1 Chao Wang, Yu Yang*, Aarti Gupta, and Ganesh Gopalakrishnan* NEC Laboratories America, Princeton, NJ * University of Utah, Salt Lake City, UT Dynamic

Motivating Example

9

Traces: a1-a4,a5-a8, a9-a11,b1-b7,b8-b11 a1-a4,a5-a8, b1-b7,a9-a11,b8-b11 a1-a4,a5-a8, b1-b7,b8-b11,a9-a11 a1-a4,………………………………….. ……Error: b1-b7, a1-a4, a5, b8-b9, {a6,b10}

In this search sub-space, a9-a11 and b1-b11 run concurrently

This sub-space does not have data race!!!

How can we do better than that? … … lockset analysis of the sub-tree

Page 10: 1 Chao Wang, Yu Yang*, Aarti Gupta, and Ganesh Gopalakrishnan* NEC Laboratories America, Princeton, NJ * University of Utah, Salt Lake City, UT Dynamic

Lockset Analysis: is the sub-space race-free?

10

In this search sub-space, a9-a11 and b1-b11 run concurrently

For each variable access, compute the set of held locks (lockset)

This sub-space does not have data race!!!

Page 11: 1 Chao Wang, Yu Yang*, Aarti Gupta, and Ganesh Gopalakrishnan* NEC Laboratories America, Princeton, NJ * University of Utah, Salt Lake City, UT Dynamic

Identifying the locksets is a thread-local computation scalable

This reduction is beyond DPOR, but fits seamlessly with dynamic model checking

Lockset Analysis: is the sub-space race-free?

11

ReceFreeSubSpace prune away redundant equivalence classes

Page 12: 1 Chao Wang, Yu Yang*, Aarti Gupta, and Ganesh Gopalakrishnan* NEC Laboratories America, Princeton, NJ * University of Utah, Salt Lake City, UT Dynamic

12

Outline

Introduction and Related Work Motivating Example Set of Locksets Modeling Unobserved Branches Experiments Conclusions

Page 13: 1 Chao Wang, Yu Yang*, Aarti Gupta, and Ganesh Gopalakrishnan* NEC Laboratories America, Princeton, NJ * University of Utah, Salt Lake City, UT Dynamic

Problem Statement

Given a trace and state Si, ask “whether all alternative traces with the same prefix (up to Si) are race free?”

13

Page 14: 1 Chao Wang, Yu Yang*, Aarti Gupta, and Ganesh Gopalakrishnan* NEC Laboratories America, Princeton, NJ * University of Utah, Salt Lake City, UT Dynamic

Set of Locksets

14

Seg_i

Seg_j

For example, lsSet_x(seg_i) = { {f1}, {f2} } lsSet_x(seg_j) = { {f1,f2} }

Page 15: 1 Chao Wang, Yu Yang*, Aarti Gupta, and Ganesh Gopalakrishnan* NEC Laboratories America, Princeton, NJ * University of Utah, Salt Lake City, UT Dynamic

Set of Locksets: it’s conservative!

15

Seg_i

Seg_j

RaceFreeSubSpace(S, si)

• If it reports a race may be a real race• if it reports race-free indeed race-free

• When the subspace is race-free, we prune away all the related equivalence classes (of interleavings)

•Independent from (and potentially more powerful than) POR

Page 16: 1 Chao Wang, Yu Yang*, Aarti Gupta, and Ganesh Gopalakrishnan* NEC Laboratories America, Princeton, NJ * University of Utah, Salt Lake City, UT Dynamic

16

Outline

Introduction and Related Work Motivating Example Set of Locksets Modeling Unobserved Branches Experiments Conclusions

Page 17: 1 Chao Wang, Yu Yang*, Aarti Gupta, and Ganesh Gopalakrishnan* NEC Laboratories America, Princeton, NJ * University of Utah, Salt Lake City, UT Dynamic

17

The Missing Link (unobserved branches)

In collecting lsSet_x(seg_i), we have to consider all feasible branches of (seg_i), which includes

• The observed path• Unobserved paths (not-yet-executed)

(we are talking about paths in a single thread)

Page 18: 1 Chao Wang, Yu Yang*, Aarti Gupta, and Ganesh Gopalakrishnan* NEC Laboratories America, Princeton, NJ * University of Utah, Salt Lake City, UT Dynamic

Over-approximating Unobserved Branches

18

Our solution: 1.Use a priori static analysis to collect lock-info in all branches;2.Instrument the source code program

• For both branches of every if-else statement, add calls to the following functions

Page 19: 1 Chao Wang, Yu Yang*, Aarti Gupta, and Ganesh Gopalakrishnan* NEC Laboratories America, Princeton, NJ * University of Utah, Salt Lake City, UT Dynamic

Over-approximating Unobserved Branches

19

The Unobserved BranchWhat do we know? 1. it accesses variable x, with lockset {B} U ( {C}\{} ) = {B,C} 2. at the end, the held locks are {B} U ( {C}\{} ) = {B,C}

Page 20: 1 Chao Wang, Yu Yang*, Aarti Gupta, and Ganesh Gopalakrishnan* NEC Laboratories America, Princeton, NJ * University of Utah, Salt Lake City, UT Dynamic

Over-approximating Unobserved Branches

20

The Unobserved BranchWhat do we know? 1. it accesses variable x, with lockset {B} U ( {C}\{} ) = {B,C} 2. at the end, the held locks are {B} U ( {C}\{} ) = {B,C}

Page 21: 1 Chao Wang, Yu Yang*, Aarti Gupta, and Ganesh Gopalakrishnan* NEC Laboratories America, Princeton, NJ * University of Utah, Salt Lake City, UT Dynamic

Over-approximating Unobserved Branches

21

Our solution: 1.Use a priori static analysis to collect lock-info in all branches;2.Instrument the source code program

• For both branches of every if—else statement, add calls to the following functions

Page 22: 1 Chao Wang, Yu Yang*, Aarti Gupta, and Ganesh Gopalakrishnan* NEC Laboratories America, Princeton, NJ * University of Utah, Salt Lake City, UT Dynamic

22

Outline

Introduction and Related Work Motivating Example Set of Locksets Modeling Unobserved Branches Experiments Conclusions

Page 23: 1 Chao Wang, Yu Yang*, Aarti Gupta, and Ganesh Gopalakrishnan* NEC Laboratories America, Princeton, NJ * University of Utah, Salt Lake City, UT Dynamic

23

Experiments

Compared the following methods DPOR (implemented in Inspect) DPOR + Property-Driven Pruning

Benchmark programs Real Linux applications written in C using POSIX thread library From public domain (sourceforge.net; freshmeat.org, etc.)

Fdrd2 Pfscan – file scanner Aget – a ftp client for concurrently downloading segments of a large file Bzip2smt – a multithreaded version of bzip

Page 24: 1 Chao Wang, Yu Yang*, Aarti Gupta, and Ganesh Gopalakrishnan* NEC Laboratories America, Princeton, NJ * University of Utah, Salt Lake City, UT Dynamic

24

Experiments

Page 25: 1 Chao Wang, Yu Yang*, Aarti Gupta, and Ganesh Gopalakrishnan* NEC Laboratories America, Princeton, NJ * University of Utah, Salt Lake City, UT Dynamic

25

Conclusions

We present a new pruning method for stateless model checking Using a trace-based lockset analysis The reduction (in thread interleavings) is property-specific, and is

therefore is beyond POR

Significance Our method scales much better to realistic programs No bogus warnings, complete coverage

Future work Extend the pruning method to handle more general safety properties

(deadlock and assertion)