arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2301.10943cs.SE
收藏

Concrat:一个面向并发程序的C-to-Rust锁自动转换器API

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

Jaemin Hong, Sukyoung Ryu

摘要:

并发程序遭受数据竞争。为了防止数据竞争,程序员使用锁。然而,只有当程序在正确的时间获得并释放正确的锁时,它们才能消除数据竞争。C语言的锁API(人们开发了大部分遗留系统程序)并不验证锁的正确使用。另一方面,最近开发的系统程序设计语言Rust提供了一个锁API,通过类型检查来保证锁的正确使用。这使得在Rust中重写遗留系统程序成为一种很有前途的方法来改进它们的安全性。不幸的是,由于它们的锁API之间的差异,手动将C转换为Rust非常费力。即使是最先进的自动C-to-Rust转换器也保留了C锁API,希望开发人员将其替换为Rust锁API。在这项工作中,我们提出了一个自动工具,用Rust lock API替换C lock API。它促进了并发程序的C-to-Rust翻译,比当前实践更少的人力投入。我们的工具由一个Rust代码转换器(Transformer)和一个静态分析器组成,前者接受锁摘要作为输入,后者有效地生成精确的锁摘要。我们表明,Transformer是可扩展的,广泛适用的,同时保留语义,它转换66 Kbps在2.6秒,并成功地处理74%的现实世界中的程序。我们还表明,该分析仪是可扩展的和精确的,它分析66 Kbps在4.3秒。

英文摘要:

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% of real-world programs. We also show that the analyzer is scalable and precise; it analyzes 66 KLOC in 4.3 seconds.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑