一句话:将条件变量信号抽象为特殊资源,用广义依赖检测通信死锁,UnHang 工具性能开销约3%。
多线程程序中的死锁难以在部署前完全消除,因其出现依赖特定输入和线程调度,需要动态工具辅助。现有死锁检测工具主要关注锁,无法检测与条件变量相关的死锁。本文把条件变量上的 signal 抽象为一种特殊资源,将经典锁依赖扩展为广义依赖,使通信死锁也能建模为 hold-and-wait 环,并设计多种实用机制记录与分析广义依赖。作者实现了工具 UnHang。在真实应用上的实验表明,UnHang 能找到所有已知死锁并发现两个新死锁,同时仅带来约 3% 性能开销和 8% 内存开销,适合部署环境使用。
Deadlocks are notorious bugs in multithreaded programs, causing serious reliability issues. However, they are difficult to be fully expunged before deployment, as their appearances typically depend on specific inputs and thread schedules, which require the assistance of dynamic tools. However, existing deadlock detection tools mainly focus on locks, but cannot detect deadlocks related to condition variables. This paper presents a novel approach to fill this gap. It extends the classic lock dependency to generalized dependency by abstracting the signal for the condition variable as a special resource so that communication deadlocks can be modeled as hold-and-wait cycles as well. It further designs multiple practical mechanisms to record and analyze generalized dependencies. In the end, this paper presents the implementation of the tool, called UnHang. Experimental results on real applications show that UnHang is able to find all known deadlocks and uncover two new deadlocks. Overall, UnHang only imposes around 3% performance overhead and 8% memory overhead, making it a practical tool for the deployment environment.