# google/sanitizers architecture

> Architecture diagram of the GitHub repository google/sanitizers, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/google/sanitizers
- Repository: https://github.com/google/sanitizers

## Overview

##### Main Components
- Core Sanitizer Documentation & Helper Code: Represented by the README and linked wiki/issue resources. This is the “heart” that explains what each sanitizer does.
- Android Application: Under the “android” folder you have a complete Android app project. This includes both native (C/C++ via CMakeLists.txt and native-lib.cpp) and Kotlin code (MainActivity.kt) and prebuilt APKs. It acts as a client/demo for at least one sanitizer (or multiple combinations) in action.
- Buildbot System: The “buildbot” directory contains scripts (install_deps.sh, start_script.sh) that likely serve continuous integration or build automation tasks. This component is responsible for setting up dependencies and scripting builds/tests.
- Dashboard Service: Found in the “dashboard” directory, this Go-based component (dashboard.go, go.mod, go.sum) is probably used for visualizing build, test, or sanitizer results.
- Research and Experimentation: Two distinct educational/research modules exist:
○ GWP-ASAN: Provides research artifacts such as papers, Makefiles, LaTeX source (for icse2024 papers) and presentation slides. This component demonstrates academic/research work around gating or sampling in AddressSanitizer.
○ HWAddress-Sanitizer and MemorySanitizer: These include experimental or demonstration code (scripts like create_qemu_image.sh, check_registers, sample source code in C/C++ and Python) and supplemental documentation (PDFs, markdown guides). The “mte-dynamic-carveout” directory also indicates a specialized case study for memory tagging extensions.

##### Relationships and Interactions
- Central Documentation & Helper Code (README and wiki-linked docs) provide context for all the components.
- The Android app both uses and demonstrates sanitization techniques (leveraging aspects of the sanitizers) and might serve as a testbed for applying sanitizers in mobile environments.
- The Buildbot scripts serve as an orchestrator, automating builds/tests that might involve compiling the Android app and running other builds/sanitizer checks.
- Dashboard connects with build/test systems, offering a visual presentation of sanitizer results, metrics, or diagnostics.
- Research components (GWP-ASAN, HWASAN, MemorySanitizer, mte-dynamic-carveout) are more loosely coupled but are essential for understanding implementation nuances and experimental validation. They may feed back insights into future sanitizer improvements.

##### Architectural Patterns & Design Principles
- Modular Organization: Each directory represents an individual module or micro-project with a well-defined purpose, from demo apps to build automation, and research documents.
- Separation of Concerns: The project obviously segregates components by their role: client demos (android), automation (buildbot), monitoring (dashboard), and research (gwp-asan, hwaddress-sanitizer).

##### Technologies & Frameworks
- Android Development (Java/Kotlin, Gradle, CMake for native code).
- Go for the Dashboard component.
- Shell scripting for build automation.
- LaTeX/Makefiles for academic papers in the GWP-ASAN component.
- C/C++ example code and Python scripts in experimental modules.
- Integration references to LLVM and its sanitizers.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Main Components
    Documentation["Documentation & Core Info"]:::docinfo
    AndroidDemo["Android Demo App"]:::app
    Buildbot["Build Automation (Buildbot)"]:::automation
    Dashboard["Dashboard Service"]:::dashboard
    External["LLVM Sanitizers Core\n(External Integration)"]:::external

    %% Research Modules Subgraph
    subgraph "Research Modules"
        GWPASAN["GWP-ASAN"]:::research
        HWASAN["HWAddress-Sanitizer"]:::research
        MemorySanitizer["MemorySanitizer"]:::research
        MTE["MTE Dynamic Carveout"]:::research
    end

    %% Relationships and Interactions
    Documentation -->|"Supports"| AndroidDemo
    Documentation -->|"Supports"| Buildbot
    Documentation -->|"Supports"| Dashboard
    Documentation -->|"Supports"| GWPASAN
    Documentation -->|"Supports"| HWASAN
    Documentation -->|"Supports"| MemorySanitizer
    Documentation -->|"Supports"| MTE

    Buildbot -->|"SendsStatus"| Dashboard

    AndroidDemo -->|"Uses"| External
    Buildbot -->|"IntegratesWith"| External
    Dashboard -->|"ReportsTo"| External
    GWPASAN -->|"ResearchInfo"| External
    HWASAN -->|"ResearchInfo"| External
    MemorySanitizer -->|"ResearchInfo"| External
    MTE -->|"ResearchInfo"| External

    %% Styles
    classDef docinfo fill:#f9c,stroke:#333,stroke-width:2px;
    classDef app fill:#bbf,stroke:#333,stroke-width:2px;
    classDef automation fill:#aff,stroke:#333,stroke-width:2px;
    classDef dashboard fill:#cfc,stroke:#333,stroke-width:2px;
    classDef research fill:#fea,stroke:#333,stroke-width:2px;
    classDef external fill:#fcc,stroke:#333,stroke-width:2px;

    %% Click Events
    click Documentation "https://github.com/google/sanitizers/blob/master/README.md"
    click AndroidDemo "https://github.com/google/sanitizers/tree/master/android/app"
    click Buildbot "https://github.com/google/sanitizers/tree/master/buildbot"
    click Dashboard "https://github.com/google/sanitizers/tree/master/dashboard"
    click GWPASAN "https://github.com/google/sanitizers/tree/master/gwp-asan"
    click HWASAN "https://github.com/google/sanitizers/tree/master/hwaddress-sanitizer"
    click MemorySanitizer "https://github.com/google/sanitizers/tree/master/memory-sanitizer"
    click MTE "https://github.com/google/sanitizers/tree/master/mte-dynamic-carveout"
```
