Efficient race detection in the presence of programmatic event loops

An event loop is the basic scheduling mechanism for programs that respond to asynchronous events. In some frameworks, only the runtime can spin event loops, while in others, these can also be spun programmatically by event handlers. The latter provides more flexibility and helps improve responsiveness in cases where an event handler must wait for some input, for example, from the user or network. It can do so while spinning an event loop. In this paper, we consider the scheduling scheme of programmatic event loops. Programs which follow this scheme are prone to interference between a handler that is spinning an event loop and another handler that runs inside the loop. We present a happens-before based race detection technique for such programs. We exploit the structure and semantics of executions of these programs to design a sparse representation of the happens-before relation. It relates only a few pairs of operations explicitly in such a way that the ordering between any pair of operations can be inferred from the sparse representation in constant time. We have implemented our technique in an offline race detector for C/C++ programs, called SparseRacer. We discovered 13 new and harmful race conditions in 9 open-source applications using SparseRacer. So far, developers have confirmed 8 as valid bugs, and have fixed 3. These bugs arise from unintended interference due to programmatic event loops. Our sparse representation improved efficiency and gave an average speedup of 5x in race detection time.

[1]  Leslie Lamport,et al.  Time, clocks, and the ordering of events in a distributed system , 1978, CACM.

[2]  Michael D. Ernst,et al.  Finding errors in multithreaded GUI applications , 2012, ISSTA 2012.

[3]  Derek Bruening,et al.  AddressSanitizer: A Fast Address Sanity Checker , 2012, USENIX Annual Technical Conference.

[4]  John K. Ousterhout,et al.  Why Threads Are A Bad Idea , 2013 .

[5]  Nicholas Nethercote,et al.  Valgrind: a framework for heavyweight dynamic binary instrumentation , 2007, PLDI '07.

[6]  Masumi Nakamura,et al.  Programming Android , 2011 .

[7]  Willy Zwaenepoel,et al.  Flash: An efficient and portable Web server , 1999, USENIX Annual Technical Conference, General Track.

[8]  Sorin Lerner,et al.  RELAY: static race detection on millions of lines of code , 2007, ESEC-FSE '07.

[9]  Yun Zhang,et al.  Static data race detection for concurrent programs with asynchronous calls , 2009, ESEC/FSE '09.

[10]  Manu Sridharan,et al.  Effective race detection for event-driven programs , 2013, OOPSLA.

[11]  Satish Narayanasamy,et al.  Detecting and surviving data races using complementary schedules , 2011, SOSP.

[12]  Vikram S. Adve,et al.  LLVM: a compilation framework for lifelong program analysis & transformation , 2004, International Symposium on Code Generation and Optimization, 2004. CGO 2004..

[13]  Satish Narayanasamy,et al.  Race detection for event-driven mobile applications , 2014, PLDI.

[14]  Jong-Deok Choi,et al.  Hybrid dynamic data race detection , 2003, PPoPP '03.

[15]  Martin T. Vechev,et al.  Scalable race detection for Android applications , 2015, OOPSLA.

[16]  George C. Necula,et al.  EventBreak , 2014, OOPSLA.

[17]  Assaf Schuster,et al.  Toward Integration of Data Race Detection in DSM Systems , 1999, J. Parallel Distributed Comput..

[18]  Manu Sridharan,et al.  Race detection for web applications , 2012, PLDI.

[19]  H. V. Jagadish,et al.  A compression technique to materialize transitive closure , 1990, TODS.

[20]  Stephen N. Freund,et al.  FastTrack: efficient and precise dynamic race detection , 2009, PLDI '09.

[21]  Friedemann Mattern,et al.  Virtual Time and Global States of Distributed Systems , 2002 .

[22]  Alexander Aiken,et al.  Effective static race detection for Java , 2006, PLDI '06.

[23]  George C. Necula,et al.  Guided GUI testing of android apps with minimal restart and approximate learning , 2013, OOPSLA.

[24]  Atif M. Memon,et al.  Using GUI Run-Time State as Feedback to Generate Test Cases , 2007, 29th International Conference on Software Engineering (ICSE'07).

[25]  Shan Lu,et al.  ConMem: Detecting Crash-Triggering Concurrency Bugs through an Effect-Oriented Approach , 2013, TSEM.

[26]  Michael Burrows,et al.  Eraser: a dynamic data race detector for multithreaded programs , 1997, TOCS.

[27]  Assaf Schuster,et al.  Efficient on-the-fly data race detection in multithreaded C++ programs , 2003, PPoPP '03.

[28]  Steve Souders Even Faster Web Sites - Performance Best Practices for Web Developers , 2009 .

[29]  Stephen N. Freund,et al.  Type-based race detection for Java , 2000, PLDI '00.

[30]  Michael Hicks,et al.  LOCKSMITH: Practical static race detection for C , 2011, TOPL.

[31]  Michael Burrows,et al.  Eraser: a dynamic data race detector for multi-threaded programs , 1997, TOCS.

[32]  Rupak Majumdar,et al.  Race detection for Android applications , 2014, PLDI.

[33]  Xiangyu Zhang,et al.  Statically locating web application bugs caused by asynchronous calls , 2011, WWW.