Mining Resource-Operation Knowledge to Support Resource Leak Detection

Chong Wang,Yiling Lou,Xin Peng,Jianan Liu,Baihan Zou
DOI: https://doi.org/10.1145/3611643.3616315
2023-01-01
Abstract:Resource leaks, which are caused by acquired resources not being released, often result in performance degradation and system crashes. Resource leak detection relies on two essential components: identifying potential Resource Acquisition and Release (RAR) API pairs, and subsequently analyze code to uncover instances where the corresponding release API call is absent after an acquisition API call. Yet, existing techniques con.ne themselves to an incomplete pair pool, either pre-de.ned manually or mined from project-speci.c code corpus, thus limiting coverage across libraries/APIs and potentially overlooking latent resource leaks. In this work, we propose to represent resource-operation knowledge as abstract resource acquisition/release operation pairs (Abs-RAR pairs for short), and present a novel approach called M.ROK to mine such Abs-RAR pairs to construct a better RAR pair pool. Given a large code corpus, M.ROK.rst mines Abs-RAR pairs with rule-based pair expansion and learning-based pair identi.cation strategies, and then instantiates these Abs-RAR pairs into concrete RAR pairs. We implement M.ROK and apply it to mine RAR pairs from a large code corpus of 1,454,224 Java methods and 20,000 Maven libraries. We then perform an extensive evaluation to investigate the mining e.ectiveness of M.ROK and the practical usage of its mined RAR pairs for supporting resource leak detection. Our results show that M.ROK mines 1,313 new Abs-RAR pairs and instantiates them into 6,314 RAR pairs with a high precision (i.e., 93.3%). In addition, by feeding our mined RAR pairs, existing approaches detect more resource leak defects in both online code examples and open-source projects.
What problem does this paper attempt to address?