修复资源包装器中的泄漏
Repairing Leaks in Resource Wrappers
AI总结:
本文提出 Arodnap,通过规范推断、程序变换、字段包含分析和新修复模式处理资源包装器泄漏,将 NJR 基准修复率从 41% 提升至 68%。
摘要:
当程序未能释放诸如 socket、文件描述符或数据库连接等有限资源时,就会发生资源泄漏。虽然可靠的静态分析工具能够检测所有泄漏,但自动修复这些泄漏仍然具有挑战性。先前的工作接收检测工具的输出,并尝试仅修复来自硬编码库资源类型列表的泄漏。这种方法限制了可修复泄漏的范围:真实世界代码使用资源包装器,这些包装器将资源存储在字段中,并且其自身必须被关闭。本文为改进存在包装器时的资源泄漏修复作出四项关键贡献。(1)它将资源管理规范的推断集成到修复流水线中,使现有修复方法能够对包装器进行推理。(2)它将程序转换为更易于分析的变体,使推断、检测和修复工具更加有效;例如,它使检测工具报告更接近根本原因的问题,通常位于资源包装器的客户端中,而不是包装器类自身内部。(3)一种新颖的字段包含分析对资源生命周期进行推理,从而能够修复更多涉及存储在字段中的资源的泄漏。(4)它引入了一种新的修复模式和更精确的推理,以更好地处理存储在非 final 字段中的资源。先前工作在 NJR 基准测试套件中修复了 41% 的资源泄漏警告;我们的实现 Arodnap 修复了 68%。
英文摘要:
A resource leak occurs when a program fails to release a finite resource like a socket, file descriptor or database connection. While sound static analysis tools can detect all leaks, automatically repairing them remains challenging. Prior work took the output of a detection tool and attempted to repair only leaks from a hard-coded list of library resource types. That approach limits the scope of repairable leaks: real-world code uses resource wrappers that store a resource in a field and must themselves be closed. This paper makes four key contributions to improve resource leak repair in the presence of wrappers. (1) It integrates inference of resource management specifications into the repair pipeline, enabling extant fixing approaches to reason about wrappers. (2) It transforms programs into variants that are easier to analyze, making inference, detection, and fixing tools more effective; for instance, it makes detection tools report problems closer to the root cause, often in a client of a resource wrapper rather than within the wrapper class itself. (3) A novel field containment analysis reasons about resource lifetimes, enabling repair of more leaks involving resources stored in fields. (4) It introduces a new repair pattern and more precise reasoning to better handle resources stored in non-final fields. Prior work fixed 41% of resource leak warnings in the NJR benchmark suite; our implementation Arodnap fixes 68%.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。