Deadlocks are one of the most notorious concurrency bugs, and significant research has focused on detecting them efficiently. Dynamic predictive analyses work by observing concurrent executions, and reason about alternative interleavings that can witness concurrency bugs. Such techniques offer scalability and sound bug reports, and have emerged as an effective approach for concurrency bug detection, such as data races. Effective dynamic deadlock prediction, however, has proven a challenging task, as no deadlock predictor currently meets the requirements of soundness, high-precision, and efficiency. In this paper, we first formally establish that this tradeoff is unavoidable, by showing that (a) sound and complete deadlock prediction is intractable, in general, and (b) even the seemingly simpler task of determining the presence of potential deadlocks, which often serve as unsound witnesses for actual predictable deadlocks, is intractable. The main contribution of this work is a new class of predictable deadlocks, called sync(hronization)-preserving deadlocks. Informally, these are deadlocks that can be predicted by reordering the observed execution while preserving the relative order of conflicting critical sections. We present two algorithms for sound deadlock prediction based on this notion. Our first algorithm SPDOffline detects all sync-preserving deadlocks, with running time that is linear per abstract deadlock pattern, a novel notion also introduced in this work. Our second algorithm SPDOnline predicts all sync-preserving deadlocks that involve two threads in a strictly online fashion, runs in overall linear time, and is better suited for a runtime monitoring setting. We implemented both our algorithms and evaluated their ability to perform offline and online deadlock-prediction on a large dataset of standard benchmarks.
翻译:死锁是最臭名昭著的并发错误之一,大量研究致力于高效检测死锁。动态预测分析通过观察并发执行过程,并推理可能见证并发错误的交替交错序列来工作。这类技术具有可扩展性和可靠的错误报告,已成为检测数据竞争等并发错误的有效方法。然而,有效的动态死锁预测被证明是一项具有挑战性的任务,因为目前尚无死锁预测器能同时满足可靠性、高精度和效率的要求。本文首先从形式上证明这种权衡是不可避免的,具体表现为:(a)可靠且完备的死锁预测在一般情况下是难解问题;(b)即便是看似更简单的任务——即判定潜在死锁的存在性(这种死锁通常作为实际可预测死锁的非可靠见证),也是难解的。本研究的主要贡献是提出了一类新的可预测死锁,称为同步保持死锁。非正式地说,这类死锁可通过重新排序观察到的执行过程并保持冲突临界区的相对顺序来预测。基于这一概念,我们提出了两种可靠的死锁预测算法。第一种算法SPDOffline能够检测所有同步保持死锁,其运行时间对每个抽象死锁模式呈线性关系——这也是本文引入的一个新概念。第二种算法SPDOnline以严格的在线方式预测涉及两个线程的所有同步保持死锁,整体运行时间为线性,更适合运行时监控场景。我们实现了这两种算法,并在标准基准程序的大型数据集上评估了它们执行离线和在线死锁预测的能力。