Concrat: An Automatic C-to-Rust Lock API Translator for Concurrent Programs

01/26/2023
by   Jaemin Hong, et al.
0

Concurrent programs suffer from data races. To prevent data races, programmers use locks. However, programs can eliminate data races only when they acquire and release correct locks at correct timing. The lock API of C, in which people have developed a large portion of legacy system programs, does not validate the correct use of locks. On the other hand, Rust, a recently developed system programming language, provides a lock API that guarantees the correct use of locks via type checking. This makes rewriting legacy system programs in Rust a promising way to retrofit safety into them. Unfortunately, manual C-to-Rust translation is extremely laborious due to the discrepancies between their lock APIs. Even the state-of-the-art automatic C-to-Rust translator retains the C lock API, expecting developers to replace them with the Rust lock API. In this work, we propose an automatic tool to replace the C lock API with the Rust lock API. It facilitates C-to-Rust translation of concurrent programs with less human effort than the current practice. Our tool consists of a Rust code transformer that takes a lock summary as an input and a static analyzer that efficiently generates precise lock summaries. We show that the transformer is scalable and widely applicable while preserving the semantics; it transforms 66 KLOC in 2.6 seconds and successfully handles 74 real-world programs. We also show that the analyzer is scalable and precise; it analyzes 66 KLOC in 4.3 seconds.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
05/02/2022

Reversing an Imperative Concurrent Programming Language

We introduce a method of reversing the execution of imperative concurren...
research
06/10/2019

SAR: Learning Cross-Language API Mappings with Little Knowledge

To save manual effort, developers often translate programs from one prog...
research
09/04/2023

Productive Development of Scalable Network Functions with NFork

Despite decades of research, developing correct and scalable concurrent ...
research
05/06/2022

Synchron – An API and Runtime for Embedded Systems

Programming embedded systems applications involve writing concurrent, ev...
research
04/27/2019

A Practical Analysis of Rust's Concurrency Story

Correct concurrent programs are difficult to write; when multiple thread...
research
10/27/2016

Fencing off Go: Liveness and Safety for Channel-based Programming (extended version)

Go is a production-level statically typed programming language whose des...
research
03/18/2023

Ownership guided C to Rust translation

Dubbed a safer C, Rust is a modern programming language that combines me...

Please sign up or login with your details

Forgot password? Click here to reset