A Mechanically Verified Garbage Collector for OCaml

被引:0
作者
Shamsu, Sheera [1 ]
Kafle, Dipesh [2 ]
Maroo, Dhruv [1 ]
Nagar, Kartik [1 ]
Bhargavan, Karthikeyan [3 ]
Sivaramakrishnan, Kc [1 ,4 ]
机构
[1] IIT Madras, Chennai 600036, India
[2] NIT Trichy, Trichy 620015, India
[3] Inria, F-75014 Paris, France
[4] Tarides, Chennai, India
关键词
Formal verification; Mark and sweep garbage collection; F*; Low*; Mechanized formal proofs; Graph traversal proofs; VERIFICATION;
D O I
10.1007/s10817-025-09721-0
中图分类号
TP18 [人工智能理论];
学科分类号
081104 ; 0812 ; 0835 ; 1405 ;
摘要
The OCaml programming language finds application across diverse domains, including systems programming, web development, scientific computing, formal verification, and symbolic mathematics. OCaml is a memory-safe programming language that uses a garbage collector (GC) to free unreachable memory. It features a low-latency, high-performance GC, tuned for functional programming. The GC has two generations-a minor heap collected using a copying collector and a major heap collected using an incremental mark-and-sweep collector. Alongside the intricacies of an efficient GC design, OCaml compiler uses efficient object representations for some object classes, such as interior pointers for supporting mutually recursive functions, which further complicates the GC design. The GC is a critical component of the OCaml runtime system, and its correctness is essential for the safety of OCaml programs. In this paper, we propose a strategy for crafting a correct, proof-oriented GC from scratch, designed to evolve over time with additional language features. Our approach neatly separates abstract GC correctness from OCaml-specific GC correctness, offering the ability to integrate further GC optimizations, while preserving core abstract GC correctness. As an initial step to demonstrate the viability of our approach, we have developed a verified stop-the-world mark-and-sweep GC for OCaml. The approach is fully mechanized in F* and its low-level subset Low*. We use the KaRaMel compiler to compile Low* to C, and integrate the verified GC with the OCaml runtime. Our GC is evaluated against off-the-shelf OCaml GC and Boehm-Demers-Weiser conservative GC, and the experimental results show that verified OCaml GC is competitive with the standard OCaml GC.
引用
收藏
页数:43
相关论文
共 38 条
[21]  
Madhavapeddy A., 2022, Real World OCaml: Functional Programming for the Masses, DOI [10.1017/9781009129220, DOI 10.1017/9781009129220]
[22]   Meta-F☆: Proof Automation with SMT, Tactics, and Metaprograms [J].
Martinez, Guido ;
Ahman, Danel ;
Dumitrescu, Victor ;
Giannarakis, Nick ;
Hawblitzel, Chris ;
Hritcu, Catalin ;
Narasimhamurthy, Monal ;
Paraskevopoulou, Zoe ;
Pit-Claudel, Clement ;
Protzenko, Jonathan ;
Ramananandro, Tahina ;
Rastogi, Aseem ;
Swamy, Nikhil .
PROGRAMMING LANGUAGES AND SYSTEMS, ESOP 2019: 28TH EUROPEAN SYMPOSIUM ON PROGRAMMING, 2019, 11423 :30-59
[23]  
Mccreight A.E., 2008, The mechanized verification of garbage collector implementations
[24]   A General Framework for Certifying Garbage Collectors and Their Mutators [J].
McCreight, Andrew ;
Shao, Zhong ;
Lin, Chunxiao ;
Li, Long .
PLDI'07: PROCEEDINGS OF THE 2007 ACM SIGPLAN CONFERENCE ON PROGRAMMING LANGUAGE DESIGN AND IMPLEMENTATION, 2007, :468-479
[25]  
Mo M.Y., 2021, Chrome in-the-wild bug analysis: CVE-2021-37975
[26]  
Myreen MO, 2010, LECT NOTES COMPUT SC, V6217, P142, DOI 10.1007/978-3-642-15057-9_10
[27]  
Protzenko J, 2018, Arxiv, DOI arXiv:1703.00053
[28]  
Ramananandro T, 2019, PROCEEDINGS OF THE 28TH USENIX SECURITY SYMPOSIUM, P1465
[29]   StarMalloc: Verifying a Modern, Hardened Memory Allocator [J].
Reitz, Antonin ;
Fromherz, Aymeric ;
Protzenko, Jonathan .
PROCEEDINGS OF THE ACM ON PROGRAMMING LANGUAGES-PACMPL, 2024, 8 (OOPSLA2)
[30]  
Reynolds J.C., 2002, P 17 ANN IEEE S LOG