Preprint Article Version 1 This version is not peer-reviewed

SafeMD:Ownership-based Safe Memory Deallocation for C Programs

Version 1 : Received: 29 September 2024 / Approved: 30 September 2024 / Online: 2 October 2024 (04:56:20 CEST)

How to cite: Yin, X.; Huang, Z.; Kan, S.; Shen, G. SafeMD:Ownership-based Safe Memory Deallocation for C Programs. Preprints 2024, 2024092413. https://doi.org/10.20944/preprints202409.2413.v1 Yin, X.; Huang, Z.; Kan, S.; Shen, G. SafeMD:Ownership-based Safe Memory Deallocation for C Programs. Preprints 2024, 2024092413. https://doi.org/10.20944/preprints202409.2413.v1

Abstract

Rust is a relatively new programming language that aims to provide memory safety at compile time. It introduces a novel ownership system which enforces automatic deallocation of unused resources without using the garbage collector. In light of Rust's promise of safety, a natural question arises about the possible benefits of exploiting ownership to ensure memory safety of C programs. In our previous work, we developed a formal ownership checker to verify whether a C program follows ownership constraints. A C program that satisfies the ownership constraints is free of dangling pointers. In this paper, we further propose a static ownership-based safe memory deallocation approach, named SafeMD, to ensure memory-leak free in the C programs that satisfy ownership constraints defined in prior formal ownership checker. Benefitting from the C programs satisfying ownership constraints, SafeMD obviates alias and inter-procedural analysis during the finding of fixing patches. Also, the patches generated by SafeMD make the input C programs still satisfy ownership constraints. Usually, a C program that satisfies the ownership constraints is safer than its normal version. Our evaluation shows that SafeMD is effective in fixing memory leaks of C programs that satisfy ownership constraints.

Keywords

C; memory leaks; memory deallocation; Rust; ownership

Subject

Computer Science and Mathematics, Software

Comments (0)

We encourage comments and feedback from a broad range of readers. See criteria for comments and our Diversity statement.

Leave a public comment
Send a private comment to the author(s)
* All users must log in before leaving a comment
Views 0
Downloads 0
Comments 0


×
Alerts
Notify me about updates to this article or when a peer-reviewed version is published.
We use cookies on our website to ensure you get the best experience.
Read more about our cookies here.