Sign up to save tools and stay up to date with the latest in AI
bg
bg
1

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

Dec 31, 2024 - arxiv.org
The article discusses the vulnerabilities of the C programming language, particularly due to manual memory management and unsafe pointer operations, and presents Rust as a safer alternative. Rust's ownership model and type system provide memory safety without compromising performance. The paper introduces Syzygy, an automated method for translating C code into safe Rust. This method leverages a combination of large language model (LLM)-driven code and test translation, guided by execution information from dynamic analysis. The translation process is incremental, maintaining correctness at each step by following the dependency order of code elements.

The authors applied Syzygy to translate Zopfli, a high-performance compression library consisting of approximately 3000 lines of code and 98 functions. The translation's validity was confirmed by testing its equivalence with the original C program using a set of inputs. This work represents the largest automated and test-validated translation from C to safe Rust to date, highlighting the potential of combining LLMs and dynamic analysis for scalable code generation and testing.

Key takeaways:

```html
  • C is widely used in high-performance systems programming but is prone to vulnerabilities due to manual memory management.
  • Rust offers memory safety through its ownership model and type system without compromising performance.
  • Syzygy is an automated approach that translates C to safe Rust using a combination of LLM-driven code translation and dynamic analysis.
  • The approach was successfully applied to translate Zopfli, a 3000-line compression library, validating the translation through equivalence testing.
```
View Full Article

Comments (0)

Be the first to comment!