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.
Similar content being viewed by others
Notes
The Clang fork supporting C++ contracts has been open-sourced and accessible at https://github.com/arcosuc3m/clang-contracts/. CSV can be found in branch CSV-src.
It may fail detecting a violation (depending on the execution order).
References
Artho C, Havelund K, Biere A (2003) High-level data races. Softw Test Verif Reliab 13(4):207–227
Blechmann T (2011) Chapter 17. Boost.Lockfree. https://www.boost.org/doc/libs/1_54_0/doc/html/lockfree.html
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
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–230
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
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
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–303
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
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
Intel: Inspector XE 2017. https://software.intel.com/en-us/intel-inspector-xe
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
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
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
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 75
Lidbury C, Donaldson AF (2017) Dynamic race detection for c++11. SIGPLAN Not 52(1):443–457. https://doi.org/10.1145/3093333.3009857
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
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–275
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
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
O’Callahan R, Choi JD (2003) Hybrid dynamic data race detection. SIGPLAN Not 38(10):167–178
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
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 2018
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–411
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). ACM
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–114
Shalev O, Shavit N (2006) Split-ordered lists: lock-free extensible hash tables. J ACM 53(3):379–405
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–212
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
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).
Author information
Authors and Affiliations
Corresponding author
Additional information
Publisher's Note
Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Rights and permissions
About this article
Cite this article
López-Gómez, J., del Rio Astorga, D., Dolz, M.F. et al. Detecting semantic violations of lock-free data structures through C++ contracts. J Supercomput 76, 5057–5078 (2020). https://doi.org/10.1007/s11227-019-02827-4
Published:
Issue Date:
DOI: https://doi.org/10.1007/s11227-019-02827-4