| Bibliography | Keil, Christian: Automated Detection of Blocking Calls in Cooperatively Scheduled Environments. University of Stuttgart, Faculty of Computer Science, Electrical Engineering, and Information Technology, Bachelor Thesis No. 72 (2025). 39 pages, english.
|
| Abstract | Former methods for concurrency in C++ relied on preemptive multitasking with threads, which was a common but complex model. These threads are scheduled by the operating system, which often introduce complications, like race conditions and deadlocks, which demand synchronization logic. To prevent these, cooperative multitasking has emerged as an alternative. C++ coroutines implement this by confining tasks to a single execution thread where they must voluntarily yield control. While this approach avoids the concurrency dangers of preemptive threads, it introduces an important requirement, the non-blocking contract. Compliance with this contract is important for system performance. If a coroutine violates the contract by making a blocking call, the entire shared execution thread is stopped. This immediately freezes all other cooperative tasks running on that thread, which leads to performance deficiencies. In the past, detecting these blocking violations has been a very inefficient process, which relied on manual code reviews. However, for large codebases, manually inspecting every function call is infeasible. Furthermore, runtime testing is also often insufficient, as these violations frequently manifest as rare bugs that are nearly impossible to reproduce. This necessitates an automated solution for immediate feedback.
This thesis addressed this by developing an automated solution using static code analysis. Central to this solution is the development of plugins for the Clang and Clang-Tidy toolchains. The tool operates directly on the Abstract Syntax Tree (AST) to systematically identify blocking calls in coroutines. In this process, all function calls in the coroutine body are checked against a predefined list of known blocking calls, and potential violations are flagged. Furthermore, the Clang-Tidy plugin provides a FixItHint, allowing developers to automatically correct the blocking calls it identifies. The main contribution of this work is therefore a tool which provides developers with quick feedback directly within their Integrated Development Environment (IDE). The effectiveness was demonstrated through an evaluation, covering the detection of direct, nested, and template- instantiated blocking calls, and also a negative test case was conducted. By automating the detection of blocking calls in coroutine bodies, the solution helps prevent performance deficiencies of C++ coroutine systems.
|