breadcrumbs: efficient context sensitivity for dynamic bug detection analyses

50
Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses Michael D. Bond University of Texas at Austin Graham Z. Baker Tufts / MIT Lincoln Laboratory We don't make a lot of the bug detectors you use. We make a lot of the bug detectors you use better . Samuel Z. Guyer Tufts University

Upload: chip

Post on 23-Feb-2016

49 views

Category:

Documents


0 download

DESCRIPTION

Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses. We don't make a lot of the bug detectors you use. We make a lot of the bug detectors you use better . Graham Z. Baker Tufts / MIT Lincoln Laboratory. Michael D. Bond University of Texas at Austin. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

Michael D. Bond

University of Texas at Austin

Graham Z. BakerTufts / MIT Lincoln Laboratory

We don't make a lot of the bug detectors you use. We make a lot of the bug detectors you use better.

Samuel Z. GuyerTufts University

Page 2: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

Example: Dynamic data race detector

Thread A Thread Bwrite x

unlock mlock mwrite x

read x

Page 3: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

Example: dynamic data race detector

Thread A Thread Bwrite x

unlock mlock mwrite x

read xrace!

Page 4: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

Example: dynamic data race detector

Thread A Thread Bwrite x

unlock mlock mwrite x

read xrace!

T@A

T’@B

T’’@A

Page 5: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

Example: dynamic data race detector

Thread A Thread Bwrite x

unlock mlock mwrite x

read xrace!

How is this race reported?

T@A

T’@B

T’’@A

Page 6: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

Reporting a race

Thread A Thread Bwrite x

unlock mlock mwrite x

read x

T@A

T’@B

T’’@A

loc1

loc2

loc3

race!

Page 7: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

Reporting a race

Thread A Thread B

write xread x

race! T’@B

T’’@A

write xunlock m

lock m

T@A loc1

loc2

loc3

AbstractDataTreeNode.indexOfChild():426

AbstractDataTreeNode.storeStrings():536

Page 8: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

Reporting a race

Thread A Thread B

write xread x

race! T’@B

T’’@A

write xunlock m

lock m

T@A loc1

loc2

loc3

AbstractDataTreeNode.indexOfChild():426

AbstractDataTreeNode.storeStrings():536

Problem : not much information

Page 9: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

Full stack traces

Thread A Thread B

write xread x

race! T’@B

T’’@A

write xunlock m

lock m

T@A loc1

loc2

loc3

AbstractDataTreeNode.indexOfChild():426AbstractDataTreeNode.childAtOrNull():212DeltaDataTree.lookup():666 ElementTree.includes():528 Workspace.getResourceInfo():1135Resource.getResourceInfo():973Project.hasNature():479 JavaProject.hasJavaNature():224JavaProject.computeExpandedClasspath():430JavaProject.getExpandedClasspath():1444... EclipseStarter.run():376...

AbstractDataTreeNode.storeStrings():536DataTreeNode.storeStrings():343AbstractDataTreeNode.storeStrings():541DataTreeNode.storeStrings():343...ElementTree.shareStrings():706SaveManager.shareStrings():1154...StringPoolJob.shareStrings():124...Worker.run():76...

Page 10: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

Context sensitivity Big impact on static analysis

Better information Better precision

Critical in modern software: Intensive code reuse (e.g., frameworks) Many small methods Highly dynamic behavior

What about dynamic analysis?

Page 11: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

How hard is this?

Thread A Thread B

write xread x

race! T’@B

T’’@A

write xunlock m

lock m

T@A loc1

loc2

loc3

AbstractDataTreeNode.indexOfChild():426AbstractDataTreeNode.childAtOrNull():212DeltaDataTree.lookup():666 ElementTree.includes():528 Workspace.getResourceInfo():1135Resource.getResourceInfo():973Project.hasNature():479 JavaProject.hasJavaNature():224JavaProject.computeExpandedClasspath():430JavaProject.getExpandedClasspath():1444... EclipseStarter.run():376...

AbstractDataTreeNode.storeStrings():536DataTreeNode.storeStrings():343AbstractDataTreeNode.storeStrings():541DataTreeNode.storeStrings():343...ElementTree.shareStrings():706SaveManager.shareStrings():1154...StringPoolJob.shareStrings():124...Worker.run():76...

Page 12: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

How hard is this?

Thread A Thread B

write xread x

race! T’@B

T’’@A

write xunlock m

lock m

T@A loc1

loc2

loc3

AbstractDataTreeNode.indexOfChild():426AbstractDataTreeNode.childAtOrNull():212DeltaDataTree.lookup():666 ElementTree.includes():528 Workspace.getResourceInfo():1135Resource.getResourceInfo():973Project.hasNature():479 JavaProject.hasJavaNature():224JavaProject.computeExpandedClasspath():430JavaProject.getExpandedClasspath():1444... EclipseStarter.run():376...

AbstractDataTreeNode.storeStrings():536DataTreeNode.storeStrings():343AbstractDataTreeNode.storeStrings():541DataTreeNode.storeStrings():343...ElementTree.shareStrings():706SaveManager.shareStrings():1154...StringPoolJob.shareStrings():124...Worker.run():76...EAS

Y

Race discovered here

Page 13: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

How hard is this?

Thread A Thread B

write xread x

race! T’@B

T’’@A

write xunlock m

lock m

T@A loc1

loc2

loc3

AbstractDataTreeNode.indexOfChild():426AbstractDataTreeNode.childAtOrNull():212DeltaDataTree.lookup():666 ElementTree.includes():528 Workspace.getResourceInfo():1135Resource.getResourceInfo():973Project.hasNature():479 JavaProject.hasJavaNature():224JavaProject.computeExpandedClasspath():430JavaProject.getExpandedClasspath():1444... EclipseStarter.run():376...

AbstractDataTreeNode.storeStrings():536DataTreeNode.storeStrings():343AbstractDataTreeNode.storeStrings():541DataTreeNode.storeStrings():343...ElementTree.shareStrings():706SaveManager.shareStrings():1154...StringPoolJob.shareStrings():124...Worker.run():76...EAS

Y

HARD

Previously recorded

information

Page 14: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

Challenge

Many events might need context information e.g., race detector: every read and write (!)

Existing approaches Walk the stack: up to 100X slowdown Build calling context tree: 2-3X, plus space

Context

Context

Context

Context

Context

Context

Context

Context

Context

Context

Context

BUG

Page 15: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

Goal

Compact representation of calling contexts

Fast correct execution

Print out stack trace when bug detected

Efficient context sensitivity for dynamic bug detectors

Page 16: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

Starting point

Represent a calling context in 1 word ⎯PCC value

Computed online, low overhead ⎯<5%

BUT, no way to decode a PCC value

Probabilistic Calling ContextBond and McKinley OOPSLA 07

Page 17: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

With PCC: analysis is context sensitive

Thread A Thread Bwrite x

unlock mlock mwrite x

read xrace!

T@A

T’@B

T’’@A

pcc1

pcc2

pcc3

0xFE9A651B

0x59C2DF08

Page 18: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

How PCC works

Caller

Callee

m()

k()

k();

j(); h();

current PCC

callsite ID

p’ = f (p, c)

new PCC

= (3p + c) mod 232

… …

At each call site…

Page 19: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

At each call site…Caller

Callee

m()

k()

k();

j(); h();

current PCC

callsiteID

p’ = f (p, c)

new PCC

= (3p + c) mod 232

… …

p = 0 in main()……

p = f(…f( f( f(0, c0), c1), c2)…, cn)

How PCC works

Page 20: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

Breadcrumbs

Problem: decode PCC value Find a sequence of callsite IDs such that

p = f(…f( f( f(0, c0), c1), c2)…, cn)i.e., invert the hash function

Page 21: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

Breadcrumbs

Problem: decode PCC value pFind a sequence of callsite IDs such that

p = f(…f( f( f(0, c0), c1), c2)…, cn)i.e., invert the hash function

Key: f is invertible Given p’ and c

unique p such that p’ = f(p, c) “Peel off” callsites until we reach 0 (main)

3 and 232 relatively

prime

Page 22: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

Decode stack trace bottom-up

PCC value = 0x5A93CF09

g():2

Start at bottomof call stack

Page 23: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

Decode stack trace bottom-up

PCC value = 0x5A93CF09

g():2

PCC value = 0x089C3A02

Use static call graph to determine

callersand apply f-1

f-1(0x5A93CF09, g():2)

Page 24: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

Decode stack trace bottom-up

PCC value = 0x5A93CF09

g():2

d():9

PCC value = 0x0

PCC value = 0x089C3A02

PCC value = 0x59C2DF08

Continue until main() and p = 0

f-1(0x5A93CF09, g():2)

f-1(0x5A93CF09, d():9)

Page 25: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

Decode stack trace bottom-up

PCC value = 0x5A93CF09

g():2

d():9

a():5

main():44

PCC value = 0x0

PCC value = 0x089C3A02

PCC value = 0x59C2DF08

Continue until main() and p = 0

f-1(0x5A93CF09, g():2)

f-1(0x5A93CF09, d():9)

Page 26: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

Problem: blind search of call graph

e():5 f():4 g():2 …

d():9

a():5

main():44

PCC value = 0x0

b():3

PCC value = 0x5A93CF09

Statically possible

contexts >> 264

c():8h():3

j():8

Need moreinformation

Page 27: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

Idea: record per-callsite PCC values

e():5 f():4 g():2 …

d():9

a():5

main():44

c():8h():3

j():8

b():3

…Add hash table

at each call site

0x089C3A02

Page 28: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

Very easy search

e():5 f():4 g():2 …

d():9

a():5

main():44

c():8h():3

j():8

b():3

…Which caller is the right one?

PCC value = 0x5A93CF09

PCC value = 0x0

Page 29: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

Very easy search

e():5 f():4 g():2 …

d():9

a():5

main():44

c():8h():3

j():8

b():3

…Invert f to find p

PCC value = 0x5A93CF09

PCC value = 0x0

f-1(0x5A93CF09, g():2)

0x089C3A02

Page 30: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

Very easy search

e():5 f():4 g():2 …

d():9

a():5

main():44

c():8h():3

j():8

b():3

…New p value will

be in caller’s hash table

PCC value = 0x5A93CF09

PCC value = 0x0

✓✘f-1(0x5A93CF09,

g():2)

0x089C3A02

Page 31: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

Very easy search

e():5 f():4 g():2 …

d():9

a():5

main():44

c():8h():3

j():8

b():3

…And continue…

PCC value = 0x5A93CF09

PCC value = 0x0

0x59C2DF08

f-1(0x5A93CF09, d():9)

f-1(0x5A93CF09, g():2)

0x089C3A02

Page 32: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

Very easy search

e():5 f():4 g():2 …

d():9

a():5

main():44

c():8h():3

j():8

b():3

PCC value = 0x5A93CF09

PCC value = 0x0

✓ ✘0x59C2DF08

f-1(0x5A93CF09, d():9)

f-1(0x5A93CF09, g():2)

0x089C3A02

And continue…

Page 33: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

Very easy search

e():5 f():4 g():2 …

d():9

a():5

main():44

c():8h():3

j():8

b():3

PCC value = 0x5A93CF09

PCC value = 0x0

0x59C2DF08

f-1(0x5A93CF09, d():9)

f-1(0x5A93CF09, g():2)

0x089C3A02

Not really searching at all

Page 34: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

antlrcharteclip

se fophsql

dbjythonluind

expmdxala

n jbb

geomean

0 20

40

60

80

100

120

140

160

% overhead

With per-callsite setsJikesRVMDaCapo benchmarks

# set ops528m201m857m21m158

m3,624m217

m270m738m137m

PCC only

Page 35: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

Observation

e():5 f():4 g():2 …

d():9

a():5

main():44

c():8h():3

j():8

b():3

A few call sites account for a

huge fraction of cost

Page 36: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

Idea: stop tracking hot call sites

e():5 f():4 g():2

d():9

a():5

main():44

c():8h():3

j():8…

…b():3Throw out hash

table and instrumentation

Page 37: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

antlrcharteclip

se fophsql

dbjythonluind

expmdxala

n jbb

geomean

0 20

40

60

80

100

120

140

160

% overhead

t = 100,000

t = 100

t = 10,000

No threshold

t = 1,000

PCC only

Is it enough information?

Tunable “hotnes

s” threshol

d

Page 38: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

Decoding: hybrid search

e():5 f():4 g():2 …

d():9

a():5

main():44

c():8h():3

j():8…

…b():3Which caller is the right one?

PCC value = 0x5A93CF09

Page 39: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

Decoding: hybrid search

e():5 f():4 g():2 …

d():9

a():5

main():44

c():8h():3

j():8…

…b():3Which caller is the right one?

PCC value = 0x5A93CF09

✓f-1(0x5A93CF09,

g():2)

0x089C3A02

Page 40: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

Decoding: hybrid search

e():5 f():4 g():2 …

d():9

a():5

main():44

c():8h():3

j():8…

…b():3No information: must explore both paths

PCC value = 0x5A93CF09

0x59C2DF08

f-1(0x5A93CF09, d():9)

f-1(0x5A93CF09, g():2)

0x089C3A02

Page 41: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

Heuristic search (see paper)

e():5 f():4 g():2 …

d():9

a():5

main():44

c():8h():3

j():8…

…b():3Sometimes fails to decode a

context

PCC value = 0x5A93CF09

0x59C2DF08

f-1(0x5A93CF09, d():9)

f-1(0x5A93CF09, g():2)

0x089C3A02

Page 42: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

antlrcharteclip

se fophsql

dbjythonluind

expmdxala

n jbb

0 20

40

60

80

100

120

140

160

% overhead

100%

100%

100%

100%

100%

47% 47% 47% 82% 95%

100%

100%

100%

100%

100%

89% 95% 95% 97% 97%

Race detectionresults

(go to Pacer talk tomorrow!)

t = 100,000

t = 100

t = 10,000

No threshold

t = 1,000

geomean

Page 43: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

Summary

Make any dynamic bug detector context sensitive

More in the paper: Description of search algorithm What kinds of bug detectors will benefit Results for two real bug detectors

(both quantitative and qualitative) Available as patch to JikesRVM

Page 44: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

Related work

Reconstruct contexts from PC and SP [Mytkowicz et al. 2009] [Inoue and Nakatani 2009]Very low overhead, but little entropy in these values

Path profiling approach [Sumner et al. 2010]Uses multiple integers to represent calling context

exactly

Both require offline training, pre-computed infoChallenge for complex, highly dynamic software

Page 45: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

Thank You

Questions?

Page 46: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

Goals

Represent calling context compactlyEasily take place of static program locations

Fast correct executionFor deployed or field-testing environment

Decode back into stack trace when neededCould expensive, but cost paid offline

Page 47: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

Calling context representation

Calling context stored in 1 word ⎯ PCC valueEssentially a hash of sequence of call site IDs

Computed online, low overhead <5%PCC values computed incrementally, at each call site

BUT, no way to decode a PCC valueCan distinguish, but not identify calling contexts

Started with Probabilistic Calling Context Bond and McKinley OOPSLA 07

Page 48: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

Summary

Make any dynamic bug detector context sensitive

Tunable overhead/precision tradeoffSweet spot:

10% to 20% overhead at threshold 1,000 to 10,000 Challenges

Long sequences of hot callsites Deep recursion

Available as patch to JikesRVM

Page 49: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

antlrchart

eclipsefop

hsqldbjython

luindexpmd

xalanjbb

geomean

0 20 40 60 80 100 120 140 160

% overhead

Tradeoff: cost vs

decoding

t = 100,000

t = 100

t = 10,000

No threshold

t = 1,000

PCC only

Page 50: Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses

100%

100%

100%

100%

100%

antlrcharteclip

se fophsql

dbjythonluind

expmdxala

n jbb

geomean

0 20

40

60

80

100

120

140

160

% overhead

47% 47% 47% 82% 95%

100%

100%

100%

100%

100%

89% 95% 95% 97% 97%