Journal Article

TerGEC: A graph enhanced contrastive approach for program termination analysis.

Shuo Liu, Jacky W. Keung, Zhen Yang, Yihan Liao, Yishu Li
Sci. Comput. Program. 2024 10.1016/j.scico.2024.103141

Abstract

Syntax Trees (ASTs), thereby capturing intra-class semantics both syntactically and lexically. Besides, it incorporates contrastive learning to learn the discrepancy between program behaviors of termination and nontermination, thereby acquiring inter-class semantics. In addition, graph augmentation is designed to improve the robustness. Weighted contrastive loss and focal loss are also equipped in TerGEC to alleviate the classes-imbalance problem during the non-termination detection. Consequently, the whole detection process can be handled more fine-grained, and the execution can also be exempted due to the nature of deep learning. Results: We evaluate TerGEC on five datasets of both Python and C languages. Extensive experiments demonstrate TerGEC achieves the best performance overall. Among all experimented datasets, TerGEC outperforms state-of-the-art baselines by 8.20% in terms of mAP and by 17.07% in terms of AUC on average. Conclusion: TerGEC is capable of detecting non-terminating programs with high precision, showing that the combination of inter-class and intra-class learning, along with our proposed classes-imbalance solutions, is significantly effective in practice. 1. Introduction Termination analysis aims to discover non-terminating programs that are induced by improper code structures or faulty statements. These programs may execute infinitely and incur various bugs, such as denial-of-service vulnerability and memory exhaustion. * Corresponding author. E-mail addresses: sliu273-c@my.cityu.edu.hk (S. Liu), Jacky.Keung@cityu.edu.hk (J.W. Keung), zhenyang@sdu.edu.cn (Z. Yang), yihanliao4-c@my.cityu.edu.hk (Y. Liao), yishuli5-c@my.cityu.edu.hk (Y. Li). https://doi.org/10.1016/j.scico.2024.103141 Received 7 August 2023; Received in revised form 11 May 2024; Accepted 11 May 2024 Available online 15 May 2024 0167-6423/© 2024 Elsevier B.V. All rights are reserved, including those for text and data mining, AI training, and similar technologies. Science of Computer Programming 237 (2024) 103141 S. Liu, J.W. Keung, Z. Yang et al. Therefore, many researchers have devoted themselves to this field. Fig. 2 illustrates an example of the non-termination issue. It c

Keywords