arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2306.11953cs.SEcs.PL
收藏

资源管理规范的推理

Inference of Resource Management Specifications

Narges Shadab, Pritam Gharat, Shrey Tiwari, Michael D. Ernst, Martin Kellogg, Shuvendu Lahiri, Akash Lal, Manu Sridharan

AI总结:

本文提出一种基于不动点的自动推理技术,从 Java 和 C# 程序中推断资源管理规范,以降低手动注解负担并扩大资源泄漏验证的适用性,实验显示可推理出 85.5% 的手写注解且误报率相近。

摘要:

当程序在不再需要某个有限资源后未能释放它时,就会发生资源泄漏。此类泄漏是现实世界中崩溃和性能问题的重要原因。最近的工作提出了一种基于检查资源管理规范来防止资源泄漏的方法。资源管理规范表达了程序如何分配资源、传递资源以及释放资源;它还跟踪对象与资源之间的所有权关系,以及对象之间的别名关系。虽然这种“先规范后验证”的方法与先前技术相比具有若干优势,但手动编写注解的需求对其实际采用构成了重大障碍。本文提出了一种新颖的技术,可以自动推理程序的资源管理规范,从而扩大资源泄漏的规范检查验证方法的适用范围。该领域的推理具有挑战性,因为资源管理规范在本质上与大多数推理技术所针对的类型存在显著差异。此外,为了实际有效性,我们希望有一种技术能够推理出开发者所预期的资源管理规范,即使在代码并未完全符合该规范的情况下也是如此。我们通过一组精心设计以捕捉现实世界编码模式的推理规则来应对这些挑战,从而产生一种有效的基于不动点的推理算法。我们已经在两个不同的系统中实现了我们的推理算法,分别针对用 Java 和 C# 编写的程序。在一项实验评估中,我们的技术推理出了程序员为基准测试手动编写的 85.5% 的注解。此外,在使用手动编写的注解和自动推理出的注解时,验证器发出的误报率几乎相同。

英文摘要:

A resource leak occurs when a program fails to free some finite resource after it is no longer needed. Such leaks are a significant cause of real-world crashes and performance problems. Recent work proposed an approach to prevent resource leaks based on checking resource management specifications. A resource management specification expresses how the program allocates resources, passes them around, and releases them; it also tracks the ownership relationship between objects and resources, and aliasing relationships between objects. While this specify-and-verify approach has several advantages compared to prior techniques, the need to manually write annotations presents a significant barrier to its practical adoption. This paper presents a novel technique to automatically infer a resource management specification for a program, broadening the applicability of specify-and-check verification for resource leaks. Inference in this domain is challenging because resource management specifications differ significantly in nature from the types that most inference techniques target. Further, for practical effectiveness, we desire a technique that can infer the resource management specification intended by the developer, even in cases when the code does not fully adhere to that specification. We address these challenges through a set of inference rules carefully designed to capture real-world coding patterns, yielding an effective fixed-point-based inference algorithm. We have implemented our inference algorithm in two different systems, targeting programs written in Java and C#. In an experimental evaluation, our technique inferred 85.5% of the annotations that programmers had written manually for the benchmarks. Further, the verifier issued nearly the same rate of false alarms with the manually-written and automatically-inferred annotations.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑