Repairing Leaks in Resource Wrappers
Sanjay Malakar, Michael D. Ernst, Martin Kellogg, Manu Sridharan
Abstract
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%.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Your agent calls
Luneget_paper_fulltext
Free to start. No credit card required.
Terminal
Install the CLIlune papers fulltext 11f1b06c-b660-43ca-b542-65c65f79cfa5Builds on14
- CoCoNuT: combining context-aware neural translation models using ensemble for program repairThibaud Lutellier, Hung Viet Pham, Lawrence Pang, Yitong Li et al.ISSTA 2020 · 325 citations
- A syntax-guided edit decoder for neural program repairQihao Zhu, Zeyu Sun, Yuan-an Xiao, Wenjie Zhang et al.FSE 2021 · 214 citations
- TFix: Learning to Fix Coding Errors with a Text-to-Text TransformerBerkay Berabi, Jingxuan He, Veselin Raychev, Martin T. VechevICML 2021 · 143 citations
- A Stitch in Time: Supporting Android Developers in WritingSecure CodeDuc Cuong Nguyen, Dominik Wermke, Yasemin Acar, Michael Backes et al.CCS 2017 · 125 citations
- TypeWriter: neural type prediction with search-based validationMichael Pradel, Georgios Gousios, Jason Liu, Satish ChandraFSE 2020 · 102 citations
Related papers
- From Leaks to Fixes: Automated Repairs for Resource Leak WarningsAkshay Utture, Jens PalsbergFSE 2023 · 5 citations
- Project-Level Resource Leak Detection through Agent-based Ownership Analysis and Repair Pattern VerificationChengxin Xu, Xiu Zhang, Xiaorui GongICSE 2026
- Amur: Fixing Multi-Resource Leaks Guided by Resource Flow AnalysisJinyoung Kim, Eunseok LeeASE 2025
- Lightweight and modular resource leak verificationMartin Kellogg, Narges Shadab, Manu Sridharan, Michael D. ErnstFSE 2021 · 14 citations
- AsyncLeakBench: A Curated Benchmark of Asynchronous Resource Leaks in Open-Source Java ProjectsJinyoung Kim, Jinseok Heo, Dongwook Choi, Eunseok LeeISSTA 2026
