Abstract
The intricate rules for memory ordering and synchronisation associated with the C/C++11 memory model mean that data races can be difficult to eliminate from concurrent programs. Dynamic data race analysis can pinpoint races in large and complex applications, but the state-of-the-art ThreadSanitizer (tsan) tool for C/C++ considers only sequentially consistent program executions, and does not correctly model synchronisation between C/C++11 atomic operations. We present a scalable dynamic data race analysis for C/C++11 that correctly captures C/C++11 synchronisation, and uses instrumentation to support exploration of a class of non sequentially consistent executions. We concisely define the memory model fragment captured by our instrumentation via a restricted axiomatic semantics, and show that the axiomatic semantics permits exactly those executions explored by our instrumentation. We have implemented our analysis in tsan, and evaluate its effectiveness on benchmark programs, enabling a comparison with the CDSChecker tool, and on two large and highly concurrent applications: the Firefox and Chromium web browsers. Our results show that our method can detect races that are beyond the scope of the original tsan tool, and that the overhead associated with applying our enhanced instrumentation to large applications is tolerable.
- S. Adve. Data races are evil with no exceptions: Technical perspective. Commun. ACM, 53:84–84, 2010. Google Scholar
Digital Library
- J. Alglave, D. Kroening, V. Nimal, and M. Tautschnig. Software verification for weak memory via program transformation. In ESOP, pages 512–532, 2013. Google Scholar
Digital Library
- J. Alglave, L. Maranget, and M. Tautschnig. Herding cats: Modelling, simulation, testing, and data mining for weak memory. ACM Trans. Program. Lang. Syst., 36(2):7:1–7:74, 2014. Google Scholar
Digital Library
- J. Alglave, M. Batty, A. F. Donaldson, G. Gopalakrishnan, J. Ketema, D. Poetzl, T. Sorensen, and J. Wickerson. GPU concurrency: Weak behaviours and programming assumptions. In ASPLOS, pages 577– 591, 2015. Google Scholar
Digital Library
- M. Batty, S. Owens, S. Sarkar, P. Sewell, and T. Weber. Mathematizing C++ concurrency: The post-Rapperswil model. Technical Report N3132=10-0122, JTC1/SC22/WG21 – The C++ Standards Committee, 2010.Google Scholar
- M. Batty, S. Owens, S. Sarkar, P. Sewell, and T. Weber. Mathematizing C++ concurrency. In POPL, pages 55–66, 2011. Google Scholar
Digital Library
- M. Batty, K. Memarian, S. Owens, S. Sarkar, and P. Sewell. Clarifying and compiling C/C++ concurrency: from C++ 11 to POWER. In POPL, pages 509–520, 2012. Google Scholar
Digital Library
- M. Batty, A. F. Donaldson, and J. Wickerson. Overhauling SC atomics in C11 and OpenCL. In POPL, pages 634–648, 2016. Google Scholar
Digital Library
- J. C. Blanchette, T. Weber, M. Batty, S. Owens, and S. Sarkar. Nitpicking C++ concurrency. In PPDP, pages 113–124, 2011. Google Scholar
Digital Library
- M. Cao, J. Roemer, A. Sengupta, and M. D. Bond. Prescient memory: exposing weak memory model behavior by looking into the future. In ISMM, pages 99–110, 2016. Google Scholar
Digital Library
- S. Chakraborty and V. Vafeiadis. Validating optimizations of concurrent C/C++ programs. In CGO, pages 216–226, 2016. Google Scholar
Digital Library
- M. Doko and V. Vafeiadis. A program logic for C11 memory fences. In VMCAI, pages 413–430, 2016. Google Scholar
Digital Library
- T. Elmas, S. Qadeer, and S. Tasiran. Goldilocks: a race-aware Java runtime. Commun. ACM, 53(11):85–92, 2010. Google Scholar
Digital Library
- D. R. Engler and K. Ashcraft. RacerX: effective, static detection of race conditions and deadlocks. In SOSP, pages 237–252, 2003. Google Scholar
Digital Library
- C. Flanagan and S. N. Freund. FastTrack: efficient and precise dynamic race detection. In PLDI, pages 121–133, 2009. Google Scholar
Digital Library
- C. Flanagan and S. N. Freund. Adversarial memory for detecting destructive races. In PLDI, pages 244–254, 2010. Google Scholar
Digital Library
- C. Flanagan and P. Godefroid. Dynamic partial-order reduction for model checking software. In POPL, pages 110–121, 2005. Google Scholar
Digital Library
- Google. KernelThreadSanitizer, a fast data race detector for the Linux kernel, visited November 2016.Google Scholar
- https://github.com/google/ ktsan.Google Scholar
- ISO/IEC. Programming languages – C. International standard 9899:2011, 2011.Google Scholar
- ISO/IEC. Programming languages – C++. International standard 14882:2011, 2011.Google Scholar
- A. Itzkovitz, A. Schuster, and O. Zeev-Ben-Mordehai. Toward integration of data race detection in DSM systems. J. Parallel Distrib. Comput., 59(2):180–203, 1999. Google Scholar
Digital Library
- H. Jin, T. Yavuz-Kahveci, and B. A. Sanders. Java memory modelaware model checking. In TACAS, pages 220–236, 2012. Google Scholar
Digital Library
- R. Krebbers and F. Wiedijk. A typed C11 semantics for interactive theorem proving. In CPP, pages 15–27, 2015. Google Scholar
Digital Library
- O. Lahav, N. Giannarakis, and V. Vafeiadis. Taming release-acquire consistency. In POPL, pages 649–662, 2016. Google Scholar
Digital Library
- L. Lamport. Time, clocks, and the ordering of events in a distributed system. Commun. ACM, 21(7):558–565, 1978. Google Scholar
Digital Library
- C. Lidbury and A. F. Donaldson. Companion webiste for reproducibility of experiments, 2017. http://multicore.doc.ic.ac. uk/projects/tsan11/.Google Scholar
- C. Lidbury and A. F. Donaldson. Dynamic race detection for C++11: Extended version, 2017.Google Scholar
Digital Library
- https://www.doc.ic.ac.uk/ ~afd/homepages/papers/pdfs/2017/POPLExtended.pdf.Google Scholar
- F. Mattern. Virtual time and global states of distributed systems. In Proc. Workshop on Parallel and Distributed Algorithms, pages 215– 226, 1988.Google Scholar
- R. Morisset, P. Pawan, and F. Zappa Nardelli. Compiler testing via a theory of sound optimisations in the C11/C++11 memory model. In PLDI, pages 187–196, 2013. Google Scholar
Digital Library
- K. Nienhuis, K. Memarian, and P. Sewell. An operational semantics for C/C++11 concurrency. In OOPSLA, pages 111–128, 2016. Google Scholar
Digital Library
- B. Norris and B. Demsky. CDSchecker: checking concurrent data structures written with C/C++ atomics. In OOPSLA, pages 131–150, 2013. Google Scholar
Digital Library
- B. Norris and B. Demsky. A practical approach for model checking C/C++11 code. ACM Trans. Program. Lang. Syst., 38(3):10, 2016. Google Scholar
Digital Library
- Oracle Corporation. Analyzing program performance with Sun Work-Shop, Chapter 5: Lock analysis tool. http://docs.oracle.com/ cd/E19059-01/wrkshp50/805-4947/6j4m8jrnd/index.html, 2010.Google Scholar
- J. Pichon-Pharabod and P. Sewell. A concurrency semantics for relaxed atomics that permits optimisation and avoids thin-air executions. In POPL, pages 622–633, 2016. Google Scholar
Digital Library
- A. Podkopaev, I. Sergey, and A. Nanevski. Operational aspects of C/C++ concurrency. CoRR, abs/1606.01400, 2016.Google Scholar
- D. Poetzl and D. Kroening. Formalizing and checking thread refinement for data-race-free execution models. In TACAS, pages 515–530, 2016. Google Scholar
Digital Library
- E. Pozniansky and A. Schuster. Efficient on-the-fly data race detection in multihreaded C++ programs. In PPoPP, pages 179–190, 2003. Google Scholar
Digital Library
- E. Pozniansky and A. Schuster. Multirace: efficient on-the-fly data race detection in multithreaded C++ programs. Concurrency and Computation: Practice and Experience, 19(3):327–340, 2007. Google Scholar
Digital Library
- P. Pratikakis, J. S. Foster, and M. Hicks. LOCKSMITH: contextsensitive correlation analysis for race detection. In PLDI, pages 320– 331, 2006. Google Scholar
Digital Library
- G. Richards, A. Gal, B. Eich, and J. Vitek. Automated construction of JavaScript benchmarks. In OOPSLA, pages 677–694, 2011. Google Scholar
Digital Library
- S. Sarkar, K. Memarian, S. Owens, M. Batty, P. Sewell, L. Maranget, J. Alglave, and D. Williams. Synchronising C/C++ and POWER. In PLDI, pages 311–322, 2012. Google Scholar
Digital Library
- S. Savage, M. Burrows, G. Nelson, P. Sobalvarro, and T. E. Anderson. Eraser: A dynamic data race detector for multithreaded programs. ACM Trans. Comput. Syst., 15(4):391–411, 1997. Google Scholar
Digital Library
- K. Serebryany and T. Iskhodzhanov. ThreadSanitizer: Data race detection in practice. In WBIA, pages 62–71, 2009. Google Scholar
Digital Library
- T. Sorensen and A. F. Donaldson. Exposing errors related to weak memory in GPU applications. In PLDI, pages 100–113, 2016. Google Scholar
Digital Library
- N. Sterling. WARLOCK - A static data race analysis tool. In USENIX Winter, pages 97–106, 1993.Google Scholar
- V. Vafeiadis, T. Balabonski, S. Chakraborty, R. Morisset, and F. Z. Nardelli. Common compiler optimisations are invalid in the C11 memory model and what we can do about it. In POPL, pages 209– 220, 2015. Google Scholar
Digital Library
- J. W. Voung, R. Jhala, and S. Lerner. RELAY: Static race detection on millions of lines of code. In FSE, pages 205–214, 2007. Google Scholar
Digital Library
- J. Ševˇcík, V. Vafeiadis, F. Zappa Nardelli, S. Jagannathan, and P. Sewell. CompCertTSO: A verified compiler for relaxed-memory concurrency. J. ACM, 60(3):22, 2013. Google Scholar
Digital Library
- D. Vyukov. Relacy race detector, visited November 2016. http://www.1024cores.net/home/relacy-race-detector.Google Scholar
- N. Zhang, M. Kusano, and C. Wang. Dynamic partial order reduction for relaxed memory models. In PLDI, pages 250–259, 2015. Google Scholar
Digital Library
Index Terms
Dynamic race detection for C++11
Recommendations
C11Tester: a race detector for C/C++ atomics
ASPLOS '21: Proceedings of the 26th ACM International Conference on Architectural Support for Programming Languages and Operating SystemsWriting correct concurrent code that uses atomics under the C/C++ memory model is extremely difficult. We present C11Tester, a race detector for the C/C++ memory model that can explore executions in a larger fragment of the C/C++ memory model than ...
Dynamic race detection for C++11
POPL '17: Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming LanguagesThe intricate rules for memory ordering and synchronisation associated with the C/C++11 memory model mean that data races can be difficult to eliminate from concurrent programs. Dynamic data race analysis can pinpoint races in large and complex ...
Dynamic race detection techniques for interrupt-driven programs
FGIT'12: Proceedings of the 4th international conference on Future Generation Information TechnologyData races are notorious concurrency bugs that are difficult to be reproduced and may lead programs into unintended nondeterministic executions. Asynchronous interrupts introduce fine-grained parallelism into interrupt-driven programs making them prone ...







Comments