Syzygy: Dual Code-Test C to (safe) Rust Translation using LLMs and Dynamic Analysis

Fuente: arXiv
Enregistré dans:
Détails bibliographiques
Auteurs principaux: Shetty, Manish, Jain, Naman, Godbole, Adwait, Seshia, Sanjit A., Sen, Koushik
Format: Preprint
Publié: 2024
Sujets:
Accès en ligne:
Tags: Ajouter un tag
Pas de tags, Soyez le premier à ajouter un tag!
_version_ 1866913622477766656
author Shetty, Manish
Jain, Naman
Godbole, Adwait
Seshia, Sanjit A.
Sen, Koushik
author_facet Shetty, Manish
Jain, Naman
Godbole, Adwait
Seshia, Sanjit A.
Sen, Koushik
contents Despite extensive usage in high-performance, low-level systems programming applications, C is susceptible to vulnerabilities due to manual memory management and unsafe pointer operations. Rust, a modern systems programming language, offers a compelling alternative. Its unique ownership model and type system ensure memory safety without sacrificing performance. In this paper, we present Syzygy, an automated approach to translate C to safe Rust. Our technique uses a synergistic combination of LLM-driven code and test translation guided by dynamic-analysis-generated execution information. This paired translation runs incrementally in a loop over the program in dependency order of the code elements while maintaining per-step correctness. Our approach exposes novel insights on combining the strengths of LLMs and dynamic analysis in the context of scaling and combining code generation with testing. We apply our approach to successfully translate Zopfli, a high-performance compression library with ~3000 lines of code and 98 functions. We validate the translation by testing equivalence with the source C program on a set of inputs. To our knowledge, this is the largest automated and test-validated C to safe Rust code translation achieved so far.
format Preprint
id arxiv_https___arxiv_org_abs_2412_14234
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle Syzygy: Dual Code-Test C to (safe) Rust Translation using LLMs and Dynamic Analysis
Shetty, Manish
Jain, Naman
Godbole, Adwait
Seshia, Sanjit A.
Sen, Koushik
Software Engineering
Artificial Intelligence
Machine Learning
Programming Languages
I.2; D.2; D.3
Despite extensive usage in high-performance, low-level systems programming applications, C is susceptible to vulnerabilities due to manual memory management and unsafe pointer operations. Rust, a modern systems programming language, offers a compelling alternative. Its unique ownership model and type system ensure memory safety without sacrificing performance. In this paper, we present Syzygy, an automated approach to translate C to safe Rust. Our technique uses a synergistic combination of LLM-driven code and test translation guided by dynamic-analysis-generated execution information. This paired translation runs incrementally in a loop over the program in dependency order of the code elements while maintaining per-step correctness. Our approach exposes novel insights on combining the strengths of LLMs and dynamic analysis in the context of scaling and combining code generation with testing. We apply our approach to successfully translate Zopfli, a high-performance compression library with ~3000 lines of code and 98 functions. We validate the translation by testing equivalence with the source C program on a set of inputs. To our knowledge, this is the largest automated and test-validated C to safe Rust code translation achieved so far.
title Syzygy: Dual Code-Test C to (safe) Rust Translation using LLMs and Dynamic Analysis
topic Software Engineering
Artificial Intelligence
Machine Learning
Programming Languages
I.2; D.2; D.3
url https://arxiv.org/abs/2412.14234