Deadlocks are a major source of bugs in concurrent programs. They are hard to predict, because they may only occur under specific scheduling conditions. Dynamic analysis attempts to identify potential deadlocks by examining a single execution trace of the program. A standard approach involves monitoring sequences of lock acquisitions in each thread, with the goal of identifying deadlock patterns. A deadlock pattern is characterized by a cyclic chain of lock acquisitions, where each lock is held by one thread while being requested by the next. However, it is well known that not all deadlock patterns identified in this way correspond to true deadlocks, as they may be impossible to manifest under any schedule. We tackle this deficiency by proposing a new method based on partial orders to eliminate false positives: lock acquisitions must be unordered under a given partial order, and not preceded by other deadlock patterns. We prove soundness (no falsely predicted deadlocks) for the novel TRW partial order, and completeness (no deadlocks missed) for a slightly weakened variant of TRW. Both partial orders can be computed efficiently and report the same deadlocks for an extensive benchmark suite.
翻译:死锁是并发程序中错误的主要来源。由于死锁可能仅在特定调度条件下出现,因此难以预测。动态分析通过检查程序的单次执行轨迹来尝试识别潜在死锁。标准方法涉及监控每个线程中锁获取的顺序,旨在识别死锁模式。死锁模式表现为锁获取的循环链,其中每个锁被一个线程持有,同时被另一个线程请求。然而,众所周知,通过这种方式识别的死锁模式并非全部对应真实死锁,因为它们在任意调度下可能无法复现。为解决这一缺陷,我们提出了一种基于偏序关系的新方法,用于消除误报:在给定偏序关系下,锁获取必须是无序的,且不能先于其他死锁模式出现。我们证明了新型TRW偏序关系的完备性(无错误预测死锁),并证明了其弱化变体TRW的完全性(无遗漏死锁)。两种偏序关系均可高效计算,并在广泛的基准测试集上报告相同的死锁结果。