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稍弱变体的完备性(无遗漏死锁)。两种偏序均可高效计算,并在大量基准测试套件中报告相同的死锁。