← Back to Pull requests

Improve documentation for using sanitizers #1926

Merged
StanFromIreland merged 5 files (475 lines) on Oct 20, 2026 18:08 UTC
View on GitHub
StanFromIreland StanFromIreland commented on Oct 16, 2026 20:34 UTC
Author

As discussed in https://github.com/python/devguide/issues/746, this updates the information on using CPython with sanitisers. The page contained a lot of information about setting up Clang, which I removed. The devguide isn't the place for it, I presume when it was written the information was less readily available (and, nowadays you're probably not going to go through the trouble of building LLVM yourself ;-). The page is now focused on our flags/setup.

<!--
Thanks for your contribution!
Please read this comment in its entirety. It's quite important.

Pull Request title

It should describe the change to be made.

Most PRs will require an issue number. Trivial changes, like fixing a typo,
do not need an issue.
-->

Diff: 475 lines (+181 / -294) across 5 files Reviewer: encukou Review duration: 5614m
All Vouch review confidence checks passed
Residual risk 0.04 = Change Risk (0.46) × (1 − Review Confidence (0.91)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.46 · 475 lines diff across 5 files
0.46
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.91 · 5 substantive comment(s)
0.91
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
91%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.369
Real PR Conversation Timeline
8 items
read-the-docs-community[bot] read-the-docs-community[bot] commented on Oct 16, 2026 20:35 UTC
Bot

<!-- readthedocs-55693 -->

Documentation build overview

📚 CPython devguide | 🛠️ Build #35261998 | 📁 Comparing 6c0522bbf817b359a5298a78512823486f41c684 against latest (d773e39505bfaf0c4593ecdebcfb7bc200c26ac5)

<kbd> &nbsp; 🔍 Preview build &nbsp; </kbd>

<details>
<summary>6 files changed · <code>+</code> 1 added · <code>±</code> 5 modified</summary>
<br>

+ Added

  • development-tools/sanitizers/index.html
  • ± Modified

  • index.html

  • core-team/team-log/index.html

  • development-tools/clang/index.html

  • development-tools/clinic/index.html

  • security/psrt/index.html
  • </details>

    encukou encukou commented on code on Oct 19, 2026 23:01 UTC
    Code Review
    development-tools/clang.rst:1
    @@ -1,289 +0,0 @@
    -.. _clang:
    -
    -===========================
    -Dynamic analysis with Clang
    -===========================
    -
    -.. highlight:: bash
    -
    -This document describes how to use Clang to perform analysis on Python and its
    -libraries.
    -
    -This document does not cover interpreting the findings. For a discussion of
    -interpreting results, see Marshall Clow's `Testing libc++ with
    --fsanitize=undefined <https://cplusplusmusings.wordpress.com/tag/clang/>`__.  The
    -blog posting is a detailed examinations of issues uncovered by Clang in
    -``libc++``.
    -
    -The document focuses on Clang, although most techniques should generally apply
    -to GCC's sanitizers as well.
    -
    -The instructions were tested on Linux, but they should work on macOS as well.
    -Instructions for Windows are incomplete.
    -
    -
    -What is Clang?
    -==============
    -
    -Clang is the C, C++ and Objective C front-end for the LLVM compiler.  The
    -front-end provides access to LLVM's optimizer and code generator. The
    -sanitizers - or checkers - are hooks into the code generation phase to
    -instrument compiled code so suspicious behavior is flagged.
    -
    -What are sanitizers?
    -====================
    -
    -Clang sanitizers are runtime checkers used to identify suspicious and undefined
    -behavior. The checking occurs at runtime with actual runtime parameters so false
    -positives are kept to a minimum.
    -
    -There are a number of sanitizers available, but two that should be used on a
    -regular basis are the Address Sanitizer (or ASan) and the Undefined Behavior
    -Sanitizer (or UBSan). ASan is invoked with the compiler option
    -``-fsanitize=address``, and UBSan is invoked with ``-fsanitize=undefined``.  The
    -flags are passed through ``CFLAGS`` and ``CXXFLAGS``, and sometimes through
    -``CC`` and ``CXX`` (in addition to the compiler).
    -
    -A complete list of sanitizers can be found at `Controlling Code Generation
    -<https://clang.llvm.org/docs/UsersManual.html#controlling-code-generation>`__.

    Can we preserve this link? Less as a list of snaitizers and more as links to documentation of the individual sanitizers.

    Perhaps also link to https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html, with a note that GCC currently keeps these clang-compatible.

    encukou encukou commented on code on Oct 19, 2026 23:01 UTC
    Code Review
    conf.py:1
    @@ -241,7 +243,7 @@
     }
     
     intersphinx_mapping = {
    -    'python': ('https://docs.python.org/3', None),
    +    'python': ('https://docs.python.org/dev', None),

    Not saying this is a bad change, but I think it should go in a separate PR, for visibility & revertability.

    encukou encukou commented on Oct 19, 2026 23:01 UTC
    Reviewer

    Thanks for taking this on!

    StanFromIreland StanFromIreland commented on code on Oct 20, 2026 06:36 UTC
    Code Review
    conf.py:1
    @@ -241,7 +243,7 @@
     }
     
     intersphinx_mapping = {
    -    'python': ('https://docs.python.org/3', None),
    +    'python': ('https://docs.python.org/dev', None),

    It's needed for HWAsan's option, and IMO, since the devguide generally documents current information, this should be ok?

    encukou encukou commented on code on Oct 20, 2026 18:08 UTC
    Code Review
    conf.py:1
    @@ -241,7 +243,7 @@
     }
     
     intersphinx_mapping = {
    -    'python': ('https://docs.python.org/3', None),
    +    'python': ('https://docs.python.org/dev', None),

    OK, let's keep it here.

    encukou encukou approved these changes on Oct 20, 2026 18:08 UTC
    Approved Reviewer

    Thank you!

    Reviewers
    Assignees
    StanFromIreland StanFromIreland
    Labels
    risk: low confidence: 91.3% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 45.7% (MEDIUM) · Higher = larger blast radius
    45.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 91.3% · Lower = rushed or shallow review
    91.3%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 4.0% · Safe to merge
    4.0%