Advertisement

Detecting semantic violations of lock-free data structures through C++ contracts

  • Javier López-Gómez
  • David del Rio Astorga
  • Manuel F. Dolz
  • Javier FernándezEmail author
  • J. Daniel García
Article
  • 48 Downloads

Abstract

The use of synchronization mechanisms in multithreaded applications is essential on shared-memory multi-core architectures. However, debugging parallel applications to avoid potential failures, such as data races or deadlocks, can be challenging. Race detectors are key to spot such concurrency bugs; nevertheless, if lock-free data structures are used, these may emit a significant number of false positives. In this paper, we present a framework for semantic violation detection of lock-free data structures which makes use of contracts, a novel feature of the upcoming C++20, and a customized version of the ThreadSanitizer race detector. We evaluate the detection accuracy of the framework in terms of false positives and false negatives leveraging some synthetic benchmarks which make use of the SPSC and MPMC lock-free queue structures from the Boost C++ library. Thanks to this framework, we are able to check the correct use of lock-free data structures, thus reducing the number of false positives.

Keywords

Parallel programming Semantic violation detection C++ contracts Lock-free data structures 

Notes

Acknowledgements

This work has been partially funded by the Spanish Ministry of Economy and Competitiveness through Project Grant TIN2016-79637-P (BigHPC—Towards Unification of HPC and Big Data Paradigms) and the European Commission through Grant No. 801091 (ASPIDE—Exascale programmIng models for extreme data processing).

References

  1. 1.
    Artho C, Havelund K, Biere A (2003) High-level data races. Softw Test Verif Reliab 13(4):207–227CrossRefGoogle Scholar
  2. 2.
    Blechmann T (2011) Chapter 17. Boost.Lockfree. https://www.boost.org/doc/libs/1_54_0/doc/html/lockfree.html
  3. 3.
    Borkar S (2010) The exascale challenge. In: 2010 international symposium on VLSI design automation and test (VLSI-DAT), pp 2–3.  https://doi.org/10.1109/VDAT.2010.5496640
  4. 4.
    Boyapati C, Lee R, Rinard M (2002) Ownership types for safe programming: preventing data races and deadlocks. In: ACM SIGPLAN notices, vol 37, no. 11. ACM, pp 211–230Google Scholar
  5. 5.
    Choi J, Dukhan M, Liu X, Vuduc R (2014) Algorithmic time, energy, and power on candidate HPC compute building blocks. In: 2014 IEEE 28th international on Parallel and distributed processing symposium, pp 447–457.  https://doi.org/10.1109/IPDPS.2014.54
  6. 6.
    Dolz MF, Del Rio Astorga D, Fernández J, Torquati M, García JD, García-Carballeira F, Danelutto M (2017) Enabling semantics to improve detection of data races and misuses of lock-free data structures. Concurr Comput Pract Exp.  https://doi.org/10.1002/cpe.4114 Google Scholar
  7. 7.
    Dongol B (2006) Formalising progress properties of non-blocking programs. In: Liu Z, He J (eds) Formal methods and software engineering. Springer, Berlin, pp 284–303CrossRefGoogle Scholar
  8. 8.
    Engler D, Ashcraft K (2003) RacerX: effective, static detection of race conditions and deadlocks. SIGOPS Oper Syst Rev 37(5):237–252.  https://doi.org/10.1145/1165389.945468 CrossRefGoogle Scholar
  9. 9.
    Giacomoni J, Moseley T, Vachharajani M (2008) Fastforward for efficient pipeline parallelism: a cache-optimized concurrent lock-free queue. In: Proceedings of the 13th ACM SIGPLAN symposium on principles and practice of parallel programming, PPoPP ’08. ACM, NY, pp 43–52.  https://doi.org/10.1145/1345206.1345215
  10. 10.
  11. 11.
    Kokologiannakis M, Lahav O, Sagonas K, Vafeiadis V (2017) Effective stateless model checking for c/c++ concurrency. Proc ACM Program Lang 2(1):17:1–17:32.  https://doi.org/10.1145/3158105 Google Scholar
  12. 12.
    Lamport L (1978) Time, clocks, and the ordering of events in a distributed system. Commun ACM 21(7):558–565.  https://doi.org/10.1145/359545.359563 CrossRefzbMATHGoogle Scholar
  13. 13.
    Lamport L (1979) How to make a multiprocessor computer that correctly executes multiprocess programs. IEEE Trans Comput 28(9):690–691.  https://doi.org/10.1109/TC.1979.1675439 CrossRefzbMATHGoogle Scholar
  14. 14.
    Lattner C, Adve V (2004) LLVM: A compilation framework for lifelong program analysis & transformation. In: Proceedings of the international symposium on code generation and optimization: feedback-directed and runtime optimization, CGO ’04. IEEE Computer Society, Washington, p 75Google Scholar
  15. 15.
    Lidbury C, Donaldson AF (2017) Dynamic race detection for c++11. SIGPLAN Not 52(1):443–457.  https://doi.org/10.1145/3093333.3009857 CrossRefzbMATHGoogle Scholar
  16. 16.
    Lu S, Park S, Seo E, Zhou Y (2008) Learning from mistakes: a comprehensive study on real world concurrency bug characteristics. In: Proceedings of the 13th International Conference on Architectural Support for Programming Languages and Operating Systems, ASPLOS XIII. ACM, New York, pp 329–339.  https://doi.org/10.1145/1346281.1346323
  17. 17.
    Michael MM, Scott ML (1996) Simple, fast, and practical non-blocking and blocking concurrent queue algorithms. In: Proceedings of the fifteenth annual ACM symposium on principles of distributed computing, PODC ’96. ACM, New York, pp 267–275Google Scholar
  18. 18.
    Norris B, Demsky B (2013) CDSchecker: checking concurrent data structures written with C/C++ atomics. SIGPLAN Not 48(10):131–150.  https://doi.org/10.1145/2544173.2509514 CrossRefGoogle Scholar
  19. 19.
    Norris B, Demsky B (2016) A practical approach for model checking C/C++11 Code. ACM Trans Program Lang Syst 38(3):10:1–10:51.  https://doi.org/10.1145/2806886 CrossRefGoogle Scholar
  20. 20.
    O’Callahan R, Choi JD (2003) Hybrid dynamic data race detection. SIGPLAN Not 38(10):167–178CrossRefGoogle Scholar
  21. 21.
    Ou P, Demsky B (2017) Checking concurrent data structures under the C/C++11 memory model. SIGPLAN Not 52(8):45–59.  https://doi.org/10.1145/3155284.3018749 CrossRefGoogle Scholar
  22. 22.
    Reis GD, Garcia JD, Lakos J, Meredith A, Myers N, Stroustrup B (2018) Support for contract based programming in C++. ISO/IEC JTC1/SC22/WG21 Working Paper, June 2018Google Scholar
  23. 23.
    Savage S, Burrows M, Nelson G, Sobalvarro P, Anderson T (1997) Eraser: a dynamic data race detector for multithreaded programs. ACM Trans Comput Syst (TOCS) 15(4):391–411CrossRefGoogle Scholar
  24. 24.
    Schweizer H, Besta M, Hoefler T (2015) Evaluating the cost of atomic operations on modern architectures. In: 24th International Conference on Parallel Architectures and Compilation (PACT’15). ACMGoogle Scholar
  25. 25.
    Serebryany K, Potapenko A, Iskhodzhanov T, Vyukov D (2012) Dynamic race detection with LLVM compiler. In: Khurshid S, Sen K (eds) Runtime verification. Springer, Berlin, pp 110–114CrossRefGoogle Scholar
  26. 26.
    Shalev O, Shavit N (2006) Split-ordered lists: lock-free extensible hash tables. J ACM 53(3):379–405MathSciNetCrossRefzbMATHGoogle Scholar
  27. 27.
    Xie X, Xue J (2011) Acculock: accurate and efficient detection of data races. In: Proceedings of the 9th annual IEEE/ACM international symposium on code generation and optimization, CGO ’11. IEEE Computer Society, Washington, pp 201–212Google Scholar
  28. 28.
    Zhou P, Teodorescu R, Zhou Y (2007) Hard: Hardware-assisted lockset-based race detection. In: Proceedings of the 2007 IEEE 13th international symposium on high performance computer architecture, HPCA ’07. IEEE Computer Society, Washington, pp 121–132.  https://doi.org/10.1109/HPCA.2007.346191

Copyright information

© Springer Science+Business Media, LLC, part of Springer Nature 2019

Authors and Affiliations

  1. 1.Department of Computer ScienceUniversidad Carlos III de MadridLeganésSpain
  2. 2.Department of Engineering and Computer ScienceUniversitat Jaume I de CastellóCastellónSpain

Personalised recommendations