acomment
play

aComment : Mining Annotations from Comments and Code to Detect - PowerPoint PPT Presentation

aComment : Mining Annotations from Comments and Code to Detect Interrupt-Related Concurrency Bugs Lin Tan , University of Waterloo, lintan@uwaterloo.ca Yuanyuan (YY) Zhou, University of California, San Diego Yoann Padioleau, Facebook Inc. OS


  1. aComment : Mining Annotations from Comments and Code to Detect Interrupt-Related Concurrency Bugs Lin Tan , University of Waterloo, lintan@uwaterloo.ca Yuanyuan (YY) Zhou, University of California, San Diego Yoann Padioleau, Facebook Inc.

  2. OS Concurrency Bugs are a Problem • Concurrency bugs are pervasive and hard-to-detect. • Operating System (OS) concurrency bugs can bring down all applications running on top of it. • OS has a higher percentage of concurrency bugs than application software. [TanTechReport’11] • 19% of OS driver bugs are concurrency bugs. [RyzhykEuroSys’09] aComment Lin Tan 2

  3. Interrupts Complicate OS Synchronization Thread (T1) Thread (T2) Lock L Acquisition Failed Lock L Acquisition Lock L Release aComment Lin Tan 3

  4. Interrupts Complicate OS Synchronization Thread (T1) Thread (T2) L Lock L Acquisition Failed Lock L Acquisition Lock L Release aComment Lin Tan 3

  5. Interrupts Complicate OS Synchronization Thread (T1) Thread (T2) L Lock C o n t e x t L S Acquisition w i t c h Failed Lock L Acquisition Lock L Release aComment Lin Tan 3

  6. Interrupts Complicate OS Synchronization Thread (T1) Thread (T2) L Lock C o n t e x t L S Acquisition w i t c h Failed Lock L Acquisition L Lock L Release aComment Lin Tan 3

  7. Interrupts Complicate OS Synchronization Thread (T1) Thread (T2) L Lock C o n t e x t L S Acquisition w i t c h Failed Lock L Acquisition L Lock L Release aComment Lin Tan 3

  8. Interrupts Complicate OS Synchronization Thread (T1) Thread (T2) L Lock C o n t e x t L S Acquisition w i t c h Failed Lock L Acquisition L Lock L Release aComment Lin Tan 3

  9. Interrupts Complicate OS Synchronization Thread (T1) Thread (T2) L Lock C o n t e x t L S Acquisition w i t c h Failed Lock L Acquisition L Lock L Release L aComment Lin Tan 3

  10. Interrupts Complicate OS Synchronization Thread (T1) Thread (T2) L Lock C o n t e x t L S Acquisition w i t c h Failed Lock L Acquisition L Lock L Release L L aComment Lin Tan 3

  11. Interrupts Complicate OS Synchronization Thread (T1) Interrupt Handler Thread (T H ) L Lock L Acquisition Failed Lock L Acquisition 1 aComment Lin Tan 4

  12. Interrupts Complicate OS Synchronization Thread (T1) Interrupt Handler Thread (T H ) L Lock I n t e r r u p L t Acquisition Failed Lock L Acquisition 1 aComment Lin Tan 4

  13. Interrupts Complicate OS Synchronization Thread (T1) Interrupt Handler Thread (T H ) L Lock I n t e r r u p L t Acquisition Failed Lock L Acquisition L 1 aComment Lin Tan 4

  14. Interrupts Complicate OS Synchronization Thread (T1) Interrupt Handler Thread (T H ) L Lock I n t e r r u p L t Acquisition Failed Lock L Acquisition L 1 aComment Lin Tan 4

  15. Interrupts Complicate OS Synchronization Thread (T1) Interrupt Handler Thread (T H ) L Lock I n t e r r u p L t Acquisition Failed Lock L Acquisition L 1 aComment Lin Tan 4

  16. Interrupts Complicate OS Synchronization Thread (T1) Interrupt Handler Thread (T H ) L Lock I n t e r r u p L t Acquisition Deadlock Failed Lock L Acquisition L 1 aComment Lin Tan 4

  17. Interrupts Complicate OS Synchronization Should disable Thread (T1) Interrupt Handler interrupts Thread (T H ) D L Lock I n t e r r u p L t Acquisition Deadlock Failed Lock L Acquisition L 1 aComment Lin Tan 4

  18. Interrupts Complicate OS Synchronization Should disable Thread (T1) Interrupt Handler interrupts Thread (T H ) D L Lock I n t e r r u p L t Acquisition Deadlock Failed Lock L Acquisition L • Interrupts can also cause other concurrency bugs. • Hard to reason about interrupts because • Interrupts can happen at anytime. 1 • Interrupts are relatively infrequent. • OS contains many interrupt handlers. aComment Lin Tan 4

  19. State-of-Art & Our Solution • Most effective concurrency bug detection tools [SavageTOCS’97, ChoiPLDI’02, LuASPLOS’06, LuSOSP’07, HammerICSE’08, JulaOSDI’08, NaikICSE’09, BurnimICSE’10, LaiICSE’10] • do not consider interrupts • are dynamic tools designed for user-level applications. • Dynamic approaches are cumbersome for OS: • difficult to instrument OS, low level, many drivers, large code sizes, complexity, ... aComment Lin Tan 5

  20. State-of-Art & Our Solution • Most effective concurrency bug detection tools [SavageTOCS’97, ChoiPLDI’02, LuASPLOS’06, LuSOSP’07, HammerICSE’08, JulaOSDI’08, NaikICSE’09, BurnimICSE’10, LaiICSE’10] • do not consider interrupts • are dynamic tools designed for user-level applications. • Dynamic approaches are cumbersome for OS: • difficult to instrument OS, low level, many drivers, large code sizes, complexity, ... • Our Solution : Static approach with interrupts in mind aComment Lin Tan 5

  21. Goal • Infer • Precondition : If interrupts should have already been disabled or enabled upon entry to a function, and • Postcondition : If interrupts should have already been disabled or enabled upon exit from the function aComment Lin Tan 6

  22. Goal • Infer Annotations { • Precondition : If interrupts should have already been disabled or enabled upon entry to a function, and • Postcondition : If interrupts should have already been disabled or enabled upon exit from the function aComment Lin Tan 6

  23. Goal • Infer Annotations { • Precondition : If interrupts should have already been disabled or enabled upon entry to a function, and • Postcondition : If interrupts should have already been disabled or enabled upon exit from the function • From comments and code aComment Lin Tan 6

  24. Goal • Infer Annotations { • Precondition : If interrupts should have already been disabled or enabled upon entry to a function, and • Postcondition : If interrupts should have already been disabled or enabled upon exit from the function • From comments and code • Detect violations to these annotations statically aComment Lin Tan 6

  25. Inferring Annotations from Comments & Code linux/kernel/time/tick-oneshot.c: /* … Called with interrupts disabled. */ int tick_init_highres(void) {…} aComment Lin Tan 7

  26. Inferring Annotations from Comments & Code linux/kernel/time/tick-oneshot.c: /* … Called with interrupts disabled. */ /*@IRQ(D, X)*/ int tick_init_highres(void) {…} aComment Lin Tan 7

  27. Inferring Annotations from Comments & Code linux/kernel/time/tick-oneshot.c: /* … Called with interrupts disabled. */ /*@IRQ(D, X)*/ int tick_init_highres(void) {…} linux/kernel/posix-cpu-timers.c: void run_posix_cpu_timers(…) { BUG_ON(!irqs_disabled()); … } aComment Lin Tan 7

  28. Inferring Annotations from Comments & Code linux/kernel/time/tick-oneshot.c: /* … Called with interrupts disabled. */ /*@IRQ(D, X)*/ int tick_init_highres(void) {…} linux/kernel/posix-cpu-timers.c: /*@IRQ(D, X)*/ void run_posix_cpu_timers(…) { BUG_ON(!irqs_disabled()); … } aComment Lin Tan 7

  29. Our Contributions ✦ Feasible to extract annotations from comments & code • Designed new interrupt-related annotations • Generated 96,821 interrupt-related annotations & automatically detected 9 true bugs in the Linux kernel • These annotations can help developers avoid bugs. ✦ Combining comments & code help extract more annotations and detect more bugs than using comments or code alone. aComment Lin Tan 8

  30. Outline • Motivation & Contributions • Annotation Design • Annotation Extraction • From comments • From code • Annotation Propagation & Bug Detection • Results: Bug Detection & Annotation Extraction • Related Work • Conclusions aComment Lin Tan 9

  31. Annotation Language Design @IRQ (Precondition, Postcondition) aComment Lin Tan 10

  32. Annotation Language Design @IRQ ( D/E/X , D/E/X ) Read our paper for the meaning of value ‘P’. aComment Lin Tan 10

  33. Annotation Language Design @IRQ ( D/E/X , D/E/X ) Value Meaning Interrupts are disabled. D Interrupts are enabled. E X Don ʼ t care Read our paper for the meaning of value ‘P’. aComment Lin Tan 10

  34. Annotation Language Design @IRQ ( D/E/X , D/E/X ) Value Meaning Interrupts are disabled. D Interrupts are enabled. E X Don ʼ t care Example Meaning @IRQ (D, D) Interrupts are disabled on entry and remain disabled on exit. Don’t-care on entry and interrupts are enabled on exit. @IRQ (X, E) @IRQ (X, X) Our design choice: Either @IRQ (D, D) or @IRQ (E, E) Read our paper for the meaning of value ‘P’. aComment Lin Tan 10

  35. Annotation Extraction From Comments Software LOC Sentence IRQSent Linux 5.2M 1,024,624 23,662 FreeBSD 2.4M 420,013 11,117 NetBSD 3.3M 680,650 23,942 OpenSolaris 3.7M 535,073 8,074 Total 14.6M 2,660,360 66,795 • Millions of lines of comments exist in OSs. • We analyze comments as is: No need to rewrite comments. aComment Lin Tan 11

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend