Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Meta Engineering 2 min read Research hardMaster

An open source compositional deadlock detector for Android Java

Meta built a compositional static analyzer, now part of the open source Infer framework, that detects deadlocks in Android Java code without running it. Using abstract interpretation, it summarizes each method once in terms of "critical pairs": which lock it acquires while already holding a given set of locks, plus whether it runs on the main or a background thread. To scale to codebases with hundreds of millions of lines, it analyzes only the methods in a revision's modified files, then uses a heuristic to find outside methods that could deadlock with them. Deployed in CI on every commit to Meta's Android apps, it has led to over 200 fixes at about a 54% fix rate, and the analysis is proven sound and complete for an abstract language with non-deterministic control.

Assumes: abstract interpretationJava locks and threadsstatic analysis basics

Related posts

  • Open-sourcing Mariana Trench: Analyzing Android and Java app security in depth

    Meta Engineering easyNovice

    Mariana Trench is Meta's open-sourced static taint-analysis tool for Android and Java apps that finds security and privacy bugs by tracing data flows from sources (e.g., Intent.getData) to sinks (e.g., Log.w, Runtime.exec). It computes per-method models via abstract interpretation and lets security engineers write rules such as user-controlled input reaching an intent-redirection sink. Rules are refined until high-signal and then run on every pull request. Meta deliberately tolerates more false positives to catch rare exploitable edge cases, and triages results with SAPP, a post-processor that groups similar traces and visualizes source-to-sink paths. Mobile apps get this extra pre-release scrutiny because fixes depend on users installing updates.

  • Automating dead code cleanup

    Meta Engineering mediumAdept

    Meta's SCARF framework finds dead code by building a cross-language, symbol-level dependency graph from Glean and augmenting it with runtime usage data such as API endpoint logs, URI dispatch tables and async job invocations, then garbage-collects unreachable nodes, subgraphs and cycles. Switching from per-symbol classifiers to whole-graph analysis raised dead code removal in one large codebase by nearly 50%, at the cost of a longer indexing and data-pipeline cycle that makes prototyping harder. Over five years SCARF has deleted more than 100 million lines in over 370,000 change requests generated through CodemodService, with some languages auto-merged without review. BigGrep textual-reference checks act as a conservative fallback, accepting false negatives to avoid unsafe deletions.

  • How we migrated our static analyzer from Java to Rust

    Datadog Engineering mediumAdept

    Datadog rewrote the Codiga static analyzer from Java to Rust after switching its parser from ANTLR to Tree-sitter, whose Java bindings lacked features like pattern matching. The rewrite ran analysis about 3x faster with roughly 10x less memory, which matters on small CI runners. Shipping a single binary also removed the JVM dependency, so the same analyzer now runs inside the IDE. The team replaced GraalVM with deno-core as a sandboxed JavaScript rule runtime and mapped Java libraries to serde_yaml, reqwest and rayon. Learning Rust and migrating took about a month, helped by parity tests, clippy and rustfmt.

  • The Sentry Android SDK is now 20-30% faster!

    Sentry mediumAdept

    Sentry's Android SDK init time dropped 20-30% between versions 8.43.0 and 8.54.0, alongside reduced memory allocation, fixed leaks and up to 10% less background CPU. The team found bottlenecks with Perfetto traces and validated over 40 changes with Android Macrobenchmark on a clock-locked Pixel 3. Highlighted changes: the Gradle plugin writes manifest options and class-availability checks into bytecode at build time, avoiding manifest parsing and reflection (6.5% gain); a custom DSN parser replaces java.net.URI (6ms down to 1µs); and one-off threads move to shared executor pools, saving 3MB of heap from ART's 1MB thread stacks. Upgrading to SDK 8.54.0+ and Gradle plugin 6.20.0+ is enough to get the gains.

  • App stability at scale with a layered defense

    Grab Engineering mediumAdept

    Grab keeps its Android and iOS superapp stable with a layered, shift-left defense against crashes. Prevention comes first: lint rules (including custom rules written from post-mortems) block merges in CI, followed by unit, UI component, E2E and manual QA testing and a mandatory one-week Grab Early Access build that auto-tickets new crashes. At the release gate, a week-long staged rollout monitors the new version's crash rate in isolation and auto-pauses expansion, while feature flags act as kill switches. In production, hard-threshold and trend alerts, a flag-first → server-side fix → hotfix escalation ladder, automated triage with severity SLAs, and a flag-rollout history dashboard contain and diagnose crashes that slip through.

The quest for software engineering knowledge.

Look:
Layout: