DynaMine: Finding Common Error Patterns by Mining Software Revision Histories

1,818 views

Published on

Presented at ESEC/FSE 2005.

Published in: Technology, News & Politics
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,818
On SlideShare
0
From Embeds
0
Number of Embeds
72
Actions
Shares
0
Downloads
47
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

DynaMine: Finding Common Error Patterns by Mining Software Revision Histories

  1. 1. DynaMine Finding Common Error Patterns by Mining Software Revision Histories Benjamin Livshits Thomas Zimmermann Stanford University Saarland University
  2. 2. Error Pattern Iceberg null dereferences, buffer overruns, ... The usual suspects J2EE servlets Application specific Device drivers Linux code
  3. 3. Co-changed items = patterns
  4. 4. Co-added Method Calls public void createPartControl(Composite parent) { ... // add listener for editor page activation getSite().getPage().addPartListener(partListener); } public void dispose() { ... getSite().getPage().removePartListener(partListener); }
  5. 5. Co-added Method Calls public void createPartControl(Composite parent) { ... // add listener for editor page activation getSite().getPage().addPartListener(partListener); } public void dispose() { ... getSite().getPage().removePartListener(partListener); }
  6. 6. Co-added Method Calls public void createPartControl(Composite parent) { ... // add listener for editor page activation getSite().getPage().addPartListener(partListener); } co-added public void dispose() { ... getSite().getPage().removePartListener(partListener); }
  7. 7. How DynaMine Works mine CVS rank and revision patterns history mining histories filter instrument relevant method calls run the application dynamic analysis post-process usage error unlikely patterns patterns patterns report report reporting patterns bugs
  8. 8. Mining Patterns mine CVS rank and revision patterns history mining histories filter instrument relevant method calls run the application dynamic analysis post-process usage error unlikely patterns patterns patterns report report reporting patterns bugs
  9. 9. Mining Method Calls o1.addListener() Foo.java 1.12 o1.removeListener() Bar.java o2.addListener() 1.47 o2.removeListener() System.out.println() Baz.java o3.addListener() 1.23 o3.removeListener() list.iterator() iter.hasNext() iter.next() o4.addListener() Qux.java 1.41 System.out.println() o4.removeListener() 1.42
  10. 10. Finding Pairs 1 Pair o1.addListener() Foo.java 1.12 o1.removeListener() Bar.java o2.addListener() 1 Pair 1.47 o2.removeListener() System.out.println() Baz.java o3.addListener() 1.23 o3.removeListener() 2 Pairs list.iterator() iter.hasNext() iter.next() 0 Pairs o4.addListener() Qux.java 1.41 System.out.println() 0 Pairs o4.removeListener() 1.42
  11. 11. Finding Patterns Find “frequent itemsets” (with Apriori) o.enterAlignment() o.enterAlignment() o.enterAlignment() o.enterAlignment() o.exitAlignment() o.exitAlignment() o.exitAlignment() o.exitAlignment() o.redoAlignment() o.redoAlignment() o.redoAlignment() o.redoAlignment() iter.hasNext() iter.hasNext() iter.hasNext() iter.hasNext() iter.next() iter.next() iter.next() iter.next() {enterAlignment(), exitAlignment(), redoAlignment()}
  12. 12. Ranking Patterns o1.addListener() Foo.java 1.12 o1.removeListener() Bar.java o2.addListener() 1.47 o2.removeListener() Support count = System.out.println() #occurrences of a pattern Baz.java o3.addListener() 1.23 o3.removeListener() Confidence = list.iterator() strength of a pattern, P(A|B) iter.hasNext() iter.next() o4.addListener() Qux.java 1.41 System.out.println() o4.removeListener() 1.42
  13. 13. Ranking Patterns o1.addListener() Foo.java 1.12 o1.removeListener() Bar.java o2.addListener() 1.47 o2.removeListener() System.out.println() Baz.java o3.addListener() 1.23 o3.removeListener() list.iterator() iter.hasNext() iter.next() This is a fix! o4.addListener() Qux.java 1.41 System.out.println() Rank removeListener() patterns higher o4.removeListener() 1.42
  14. 14. Investigated Projects JEDIT ECLIPSE since 2000 2001 developers 92 112 lines of code 700,000 2,900,000 revisions 40,000 400,000
  15. 15. Simple Method Pairs GUIs & Listener Usage pattern o.addWidget() o.removeWidget() o.addPropertyChangeListener() o.removePropertyChangeListener() Error pattern
  16. 16. Simple Method Pairs Locking of Resources o.HLock() o.HUnlock() Not hit at runtime
  17. 17. State Machines in Eclipse Pretty-printing Usage pattern o.redoAlignment() o.enterAlignment() o.exitAlignment()
  18. 18. State Machines in Eclipse Memory context manupilation Not hit at runtime OS.PmMemFlush() OS.PmMemStart() OS.PmMemStop() OS.PmMemCreateMC() OS.PmMemReleaseMC()
  19. 19. State Machines in JEdit Compound edits (for undo/redo) Usage pattern o.insert() o.remove() o.beginCompoundEdit() o.endCompoundEdit()
  20. 20. Complex Patterns try { monitor.beginTask(null, Policy.totalWork); int depth = -1; try { workspace.prepareOperation(null, monitor); workspace.beginOperation(true); depth = workspace.getWorkManager().beginUnprotected(); ! return runInWorkspace (Policy.subMonitorFor(monitor, Policy.opWork, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK)); } catch (OperationCanceledException e) { workspace.getWorkManager().operationCanceled(); return Status.CANCEL_STATUS; } finally { if (depth >= 0) workspace.getWorkManager().endUnprotected(depth); workspace.endOperation(null, false, Policy.subMonitorFor(monitor, Policy.endOpWork)); } } catch (CoreException e) { return e.getStatus(); } finally { monitor.done(); }
  21. 21. Complex Patterns try { monitor.beginTask(null, Policy.totalWork); int depth = -1; try { workspace.prepareOperation(null, monitor); workspace.beginOperation(true); depth = workspace.getWorkManager().beginUnprotected(); ! return runInWorkspace (Policy.subMonitorFor(monitor, Policy.opWork, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK)); } catch (OperationCanceledException e) { workspace.getWorkManager().operationCanceled(); return Status.CANCEL_STATUS; } finally { if (depth >= 0) workspace.getWorkManager().endUnprotected(depth); workspace.endOperation(null, false, Policy.subMonitorFor(monitor, Policy.endOpWork)); } } catch (CoreException e) { return e.getStatus(); } finally { monitor.done(); }
  22. 22. Complex Patterns try { monitor.beginTask(null, Policy.totalWork); int depth = -1; try { workspace.prepareOperation(null, monitor); workspace.beginOperation(true); depth = workspace.getWorkManager().beginUnprotected(); ! return runInWorkspace (Policy.subMonitorFor(monitor, Policy.opWork, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK)); } catch (OperationCanceledException e) { workspace.getWorkManager().operationCanceled(); return Status.CANCEL_STATUS; } finally { if (depth >= 0) workspace.getWorkManager().endUnprotected(depth); workspace.endOperation(null, false, Policy.subMonitorFor(monitor, Policy.endOpWork)); } } catch (CoreException e) { return e.getStatus(); } finally { monitor.done(); }
  23. 23. Workspace Transactions Usage pattern S → O* O → w.prepareOperation() w.beginOperation() U* w.endOperation() U → w.getWorkManager().beginUnprotected() S [w.getWorkManager().operationCanceled()] w.getWorkManager().beginUnprotected()
  24. 24. Dynamic Validation mine CVS rank and revision patterns history mining histories filter instrument relevant method calls run the application dynamic analysis post-process usage error unlikely patterns patterns patterns report report reporting patterns bugs
  25. 25. Pattern classification post-process v validations, e violations usage error unlikely patterns patterns patterns ev/10 v/10=e=2v otherwise
  26. 26. Experiments usage pattern 15 not hit 24 error pattern 8 unlikely 11 total 56 patterns
  27. 27. Future Work Automatically generate state machines Additional patterns by textual matching Programmer assist tools Programmers who inserted a call to open() inserted a call to close() Aspect Mining
  28. 28. Contibutions DynaMine learns usage patterns from large version archives. DynaMine ranks patterns effectively, especially for finding error patterns. DynaMine increases trust in patterns by dynamic analysis

×