---
title: "Eliminating Data Races in Firefox – A Technical Report"
description: "Mozilla deployed ThreadSanitizer across Firefox's C/C++ and Rust code, using a compiled-in suppression list to gate new races in CI while legacy ones were triaged toward a \"no data races\" policy."
url: "https://swe.quest/articles/eliminating-data-races-in-firefox-a-technical-report-5763b33d1a4f6f94"
canonical: "https://hacks.mozilla.org/2021/04/eliminating-data-races-in-firefox-a-technical-report/"
source: "Mozilla Hacks"
published: "2021-04-06"
difficulty: "hard"
kind: "Case study"
reading_minutes: 11
tags: ["concurrency","c-cpp","rust","debugging","static-analysis"]
---

# Eliminating Data Races in Firefox – A Technical Report

A post on [Mozilla Hacks](https://swe.quest/sources/mozilla-hacks.md), published 2021-04-06, 11 min read, Case study. Original: [https://hacks.mozilla.org/2021/04/eliminating-data-races-in-firefox-a-technical-report/](https://hacks.mozilla.org/2021/04/eliminating-data-races-in-firefox-a-technical-report/)

## Summary

Mozilla deployed ThreadSanitizer across Firefox's C/C++ and Rust code, using a compiled-in suppression list to gate new races in CI while legacy ones were triaged toward a "no data races" policy. So-called benign races are easily misclassified, yet fixing them proved cheap: most fixes were atomics conversions, suppressions or code removal. Notable finds include lost writes from adjacent bitfields (fixed with a MOZ\_ATOMIC\_BITFIELDS macro), a PreferencesWriter race likely corrupting prefs.js, and fragile late-validated racy reads. Rust needed -Zbuild-std hacks for instrumentation but surfaced only two pure-Rust races, in parking\_lot and a WebRender shim, both in unsafe low-level code.

Written by swe.quest, not by the author.

**Difficulty:** Hard: written for specialists in the field

## Topics

- [Concurrency](https://swe.quest/tags/concurrency.md) (Compilers & runtimes)
- [C & C++](https://swe.quest/tags/c-cpp.md) (Languages)
- [Rust](https://swe.quest/tags/rust.md) (Languages)
- [Debugging](https://swe.quest/tags/debugging.md) (Engineering practices)
- [Static analysis](https://swe.quest/tags/static-analysis.md) (Engineering practices)

## Prerequisites

- C/C++ memory model ([easy posts on C & C++](https://swe.quest/tags/c-cpp.md?difficulty=easy))
- atomics and memory ordering
- multithreaded programming
- compiler sanitizers

## Keywords

ThreadSanitizer, Firefox, Clang, parking\_lot, crossbeam, WebRender, build-std

## Related posts

- [A Year of Rust in ClickHouse](https://swe.quest/articles/a-year-of-rust-in-clickhouse-fadc1c7501c80398.md): ClickHouse · 2025-04-01 · Medium · 12 min read · Rust, C & C++, Build systems, Testing, Supply chain security
  ClickHouse added Rust to its C++ codebase as an option for new components rather than a rewrite, starting with BLAKE3, then skim for clickhouse-client history, PRQL as a switchable query dialect, and Databricks' delta-kernel-rs replacing a sketchy C++ Delta Lake implementation.
- [Bun 1.4](https://swe.quest/articles/bun-1-4-fea28913dacb5d89.md): Bun · 2026-08-20 · Medium · 217 min read · Runtimes & VMs, JavaScript, Performance engineering, Memory management, Rust
  Bun 1.4 adds 1,517 newly passing Node.js test-suite tests, fixes over 2,900 issues, and rewrites Bun from Zig to Rust.
- [Enabling the parallel frontend on nightly](https://swe.quest/articles/enabling-the-parallel-frontend-on-nightly-9c56c94985e87b86.md): Rust Blog · 2026-11-16 · Medium · 6 min read · Rust, Compilers, Performance engineering, Concurrency
  Rust nightly now runs the compiler frontend (type checking, borrow checking) in parallel by default since nightly-2026-11-14, to surface bugs ahead of stabilization.
- [More Than 2x Faster Hashing in ClickHouse Using Rust](https://swe.quest/articles/more-than-2x-faster-hashing-in-clickhouse-using-rust-404bde5cc500d24b.md): ClickHouse · 2022-10-25 · Medium · 5 min read · Rust, C & C++, Build systems, Performance engineering, Cryptography
  ClickHouse added optional Rust library support to its C++/CMake build using Corrosion-rs, with BLAKE3 as the first library, exposed to C++ through a Rust shim function using C-compatible FFI types and a header file.
- [How to use Rust in ClickHouse: avoiding a full rewrite](https://swe.quest/articles/how-to-use-rust-in-clickhouse-avoiding-a-full-rewrite-e470754e07a213d4.md): ClickHouse · 2025-12-17 · Medium · 13 min read · Rust, C & C++, Build systems, Refactoring & migrations, Testing
  ClickHouse, a 1.5M-line C++ analytic database, is adopting Rust incrementally rather than rewriting.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
