Leveraging Valgrind to Assess Concurrent, Testing-Unaware C Programs
Prasun Dewan, Nalin Gaddis · 2024
Concurrent programming has allowed software to increase the power of CPUs, but is inherently error-prone because of its complexity and non-determinism. A low-level language such as C further increases the difficulty of writing concurrent programs Existing solutions for checking application-specific functional concurrency constraints do not support C and require the tested concurrent programs to be testing-aware by producing special log traces. We have developed a new framework, called Valgrind++, which uses Valgrind to instrument binary code to generate traces automatically. The framework provides (a) a mechanism to specify traced method calls, and (b) initial high-level and flexible abstractions to create tests that process the traces of these calls. These abstractions allow instructors to trade programming effort with testing accuracy based on their experience with the kind of mistakes students make and their ability to catch these mistakes manually. This paper describes Valgrind++ and how it can be used to make these tradeoffs. It presents complete tests for a series of related introductory examples for trace-based instruction on threads, context switching, locks, and conditions. It also describes a case study of a complex operating systems assignment for advanced students, which shows the potential of using Valgrind++ to save grading effort, catch manual grading errors, and provide direction to those struggling to meet the concurrency requirements.