Skip to main content
QUICK REVIEW

[Paper Review] Fearless Concurrency? Understanding Concurrent Programming Safety in Real-World Rust Software

Zeming Yu, Linhai Song|arXiv (Cornell University)|Feb 5, 2019
Software Testing and Debugging TechniquesComputer Science13 references11 citations
TL;DR

This paper presents the first empirical study of concurrent programming in real-world Rust applications, analyzing concurrency usage and bugs across three major open-source projects—Servo, TiKV, and Rand. It reveals that data races can still occur in safe Rust code due to atomic operation misuse, challenging the notion of 'fearless concurrency' and highlighting the need for advanced static and dynamic analysis tools targeting unsafe code and atomic operations.

ABSTRACT

Rust is a popular programming language in building various low-level software in recent years. It aims to provide safe concurrency when implementing multi-threaded software through a suite of compiler checking rules. Unfortunately, there is limited understanding of how the checking rules influence the safety of concurrent programming in Rust applications. In this paper, we perform a preliminary study on Rust's concurrency safety from two aspects: concurrency usage and concurrency bugs. Our study can provide better understanding on Rust's concurrency and can guide future researchers and practitioners in writing better, more reliable Rust software and in developing debugging and bug detection tools for Rust.

Motivation & Objective

  • To understand how Rust’s compiler checks influence real-world concurrent programming.
  • To investigate the prevalence and nature of concurrency bugs in production Rust software.
  • To evaluate whether Rust’s promise of 'fearless concurrency' holds in practice.
  • To inform future tool development for detecting concurrency bugs in Rust.

Proposed method

  • Conducted a static and dynamic analysis of three large, production-grade Rust applications: Servo (browser), TiKV (key-value store), and Rand (utility library).
  • Collected and analyzed source code, commit histories, and bug reports to identify concurrency patterns and bugs.
  • Identified and reverse-engineered actual concurrency bugs, particularly those involving atomic operations and unsafe code.
  • Used formal reasoning and compiler semantics to validate the root causes of data races in safe code.
  • Evaluated the impact of Rust’s ownership and borrowing system on concurrency usage patterns and programmer behavior.
  • Proposed implications for language design and tooling based on observed patterns and bugs.

Experimental results

Research questions

  • RQ1To what extent do real-world Rust applications rely on unsafe code for concurrency, and how does this affect safety?
  • RQ2Are there data races in safe Rust code, and if so, what are their root causes?
  • RQ3How do Rust’s ownership and borrowing rules influence the usage of concurrency primitives in practice?
  • RQ4What are the common patterns and anti-patterns in concurrent Rust programming as observed in real systems?
  • RQ5How do existing concurrency bug detection techniques need to be adapted for Rust, given its unique safety model?

Key findings

  • Despite Rust’s strong type system and compile-time ownership checks, data races still occur in safe Rust code, primarily due to incorrect use of atomic operations.
  • The study identified a real data race in the Rand library caused by non-atomic updates to shared state using atomic variables, which was later fixed using the Once primitive.
  • Rust’s compiler checks restrict certain programming patterns, leading developers to adopt workarounds such as using Once or unsafe code to achieve desired concurrency semantics.
  • Unsafe code remains a major source of data races, but so do atomic operations in safe code, indicating that static analysis must cover both.
  • The belief in 'fearless concurrency' is overstated—developers cannot rely solely on the compiler to prevent all concurrency bugs.
  • Future tooling for Rust should focus on detecting race conditions in unsafe code and atomic operation misuse in safe code.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.