Skip to content

infra: Dispatchable sanitizer workflow (ASan/UBSan, TSan, valgrind) - #171

Merged
zackees merged 3 commits into
masterfrom
infra/sanitizer-workflow
Oct 11, 2026
Merged

zackees merged 3 commits into
masterfrom
infra/sanitizer-workflow

Conversation

@zackees

@zackees zackees commented Oct 11, 2026

Copy link
Copy Markdown
Member

Refs #143 (claims the "ASan/UBSan variant of the Tier 2 ON build" item).

Adds a sanitizer pass that can be triggered as a GitHub Action, built from the harness used to file #128, #133 and #160.

What it does

.github/workflows/sanitizers.yaml runs one job per tool on ubuntu-26.04. Each job:

  1. installs the Tier 2 build dependencies (read from rust/tools/linux-validate/Dockerfile, so the lists can't drift) plus valgrind, Xvfb, Mesa and D-Bus;
  2. builds the tree with that tool's flags: ASan+UBSan, TSan, or a Debug build for valgrind;
  3. runs every cmocka test under the tool;
  4. launches OBS headless with a fresh profile and sends SIGINT after a timeout;
  5. writes triage.py's summary to the job summary and uploads the logs as sanitize-<tool>.

Triggers

  • workflow_dispatch with these inputs: tools (all/asan/tsan/valgrind), launch_seconds, rust_libobs (ENABLE_RUST_LIBOBS=ON) and fail_on_findings.
  • PRs that touch rust/tools/sanitize/** or the workflow, so this PR exercises it.

Once merged:

gh workflow run sanitizers.yaml -f tools=all -f rust_libobs=true

Triage rules (triage.py)

A report counts only where OBS code is where it happens:

  • ASan/UBSan: any report with an OBS frame.
  • TSan: both racing accesses must have an OBS frame in their top two frames. Races inside uninstrumented Qt/GLib/D-Bus/Mesa/PulseAudio are listed as external and not counted.
  • valgrind: memory errors with an OBS frame in the top four. Definite leaks count only when the process didn't crash.

Run on the manual results from master ad60c0e39, it reproduces the hand triage exactly: 2 ASan crashes (#126, #127), and 5 TSan reports in OBS code (the races in #130, #131 and #132) against 40 external ones.

Notes

  • Defaults: the job doesn't fail on findings (the known bugs above would fail it today). Turn on fail_on_findings once they're fixed.
  • Skipped tests: test_formatted_filename and test_utf8 hardcode ASan, so TSan and valgrind skip them (test/cmocka: hardcoded per-test -fsanitize flags break TSan/MSan builds and valgrind runs #159).
  • Local use: the same script runs locally, natively on NixOS via nix-shell rust/tools/sanitize/shell.nix --run 'rust/tools/sanitize/sanitize.sh tsan', or on Ubuntu after install-ubuntu-deps.sh.
  • Sign-off: new workflow file, added at the maintainer's explicit request.
  • Testing: no RED/GREEN, since this is CI tooling with no unit under test. This PR's own Sanitizers run is the check.

…ind)

.github/workflows/sanitizers.yaml runs rust/tools/sanitize/sanitize.sh once
per tool on ubuntu-26.04. Each job builds the tree with that tool's flags
(ENABLE_RUST_LIBOBS selectable), runs every cmocka test under it, launches OBS
headless under Xvfb with a fresh profile and closes it with SIGINT after a
timeout, then writes triage.py's summary to the job summary and uploads the
logs. It is triggered by workflow_dispatch (tools, launch time, Rust libobs,
fail-on-findings) and by PRs that change the harness.

- sanitize.sh: one script for Ubuntu and NixOS (shell.nix); valgrind runs with
  QT_ENABLE_REGEXP_JIT=0 (the PCRE2 JIT memfd is opaque to it) and full paths.
- install-ubuntu-deps.sh: the Tier 2 image's package list, read from
  rust/tools/linux-validate/Dockerfile, plus valgrind/Xvfb/Mesa/D-Bus.
- triage.py: counts a report only where OBS code is where it happens. TSan
  races must have OBS frames on both accesses; valgrind leaks are ignored after
  a crash. These are the rules used to file #128, #133 and #160.

Refs #143

Local-Gate: v1 tree=689bce76047a4fe654972487d26acc006458444b secs=177 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791677636,"gate":"rust/all/fmt","host":"linux-x86_64","key":"2f269309edac4bdcfec213dd1ac4f955d0fc07c9ab43a823ee2504849242caee","lane":"lint","parents":["29e2dfa5cb3ee8187bb78e37703980618e066026"],"secs":15,"stamp":"c5bcc4177ae6beb2bd2776139d126bd4","tree":"689bce76047a4fe654972487d26acc006458444b","v":1,"via":"run"}
Ci-Attestation: {"at":1791677636,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"2f269309edac4bdcfec213dd1ac4f955d0fc07c9ab43a823ee2504849242caee","lane":"lint","parents":["29e2dfa5cb3ee8187bb78e37703980618e066026"],"secs":15,"stamp":"245d40fa95a10eede9c886c760824cc6","tree":"689bce76047a4fe654972487d26acc006458444b","v":1,"via":"run"}
Ci-Attestation: {"at":1791677636,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"16a68186c17f58e2766c2dbe062436d7fb710f35ed72eb3faf1db90acd343b1d","lane":"rust-test","parents":["29e2dfa5cb3ee8187bb78e37703980618e066026"],"secs":43,"stamp":"4a7cd87eb2a7baa50be72ee569262fea","tree":"689bce76047a4fe654972487d26acc006458444b","v":1,"via":"run"}
Ci-Attestation: {"at":1791677636,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"1cc0c2a2f3093a51c0f591ce0003f91f81c96c44631c9b4ead2221445afe3995","lane":"tier2-linux","parents":["29e2dfa5cb3ee8187bb78e37703980618e066026"],"secs":118,"stamp":"1a0fc099a8a5226a3570900284acd8b2","tree":"689bce76047a4fe654972487d26acc006458444b","v":1,"via":"run"}
From the first workflow run (#176):

- UBSan prints to stderr even with log_path set, and recovers, so a passing
  test or the app's stderr can carry reports. triage.py now also scans the
  tests' stdout logs and app.log, counting a report seen twice once. This
  surfaced #173 and #174, which the exit codes and log files hid.
- TSan's own crash reports (ERROR: ThreadSanitizer: SEGV) are counted, not just
  WARNING races.
- Known tool limitations are listed but not counted: under valgrind,
  test_pipe's missing-binary case (posix_spawn runs as a plain fork) and
  test_svt_av1 (VEX temporary storage exhausted).
- A crash in OBS code under valgrind is a finding; --tool= overrides the tool
  that the directory name implies.
- sanitize.sh gives valgrind 240 s between SIGINT and SIGKILL.

Refs #143

Local-Gate: v1 tree=6ce7acd50e76b91ceacc4223492de8b5168cfd0a secs=69 lanes=lint:reused@9b503e30ab5a,rust-test:reused@3f31f0ee7558,tier2-linux:run
Ci-Attestation: {"at":1791679651,"gate":"rust/all/fmt","host":"linux-x86_64","key":"9b503e30ab5a1e42eb712e1a4c1ee6ed8eb7dca395f6b148e613506b5e1ed900","lane":"lint","parents":["986e0d1d601052e07301615d44ec84fa61a0a504"],"secs":null,"stamp":"d39dfc8d476574f6ef491d23a621c450","tree":"6ce7acd50e76b91ceacc4223492de8b5168cfd0a","v":1,"via":"reused"}
Ci-Attestation: {"at":1791679651,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"9b503e30ab5a1e42eb712e1a4c1ee6ed8eb7dca395f6b148e613506b5e1ed900","lane":"lint","parents":["986e0d1d601052e07301615d44ec84fa61a0a504"],"secs":null,"stamp":"d09711598f207f5d9fc803a530960f15","tree":"6ce7acd50e76b91ceacc4223492de8b5168cfd0a","v":1,"via":"reused"}
Ci-Attestation: {"at":1791679651,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"3f31f0ee75580fa32253bf463998aef2645b379a5f217d18857a16dda768c645","lane":"rust-test","parents":["986e0d1d601052e07301615d44ec84fa61a0a504"],"secs":null,"stamp":"80872b939dcb70d5e2c4e0f56f82d00e","tree":"6ce7acd50e76b91ceacc4223492de8b5168cfd0a","v":1,"via":"reused"}
Ci-Attestation: {"at":1791680917,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"98e730162a506b503ad495e8f240654ec5fc298a3ecad31b046c19df7c19b700","lane":"tier2-linux","parents":["986e0d1d601052e07301615d44ec84fa61a0a504"],"secs":69,"stamp":"9a438c39712c6aff006d694641146293","tree":"6ce7acd50e76b91ceacc4223492de8b5168cfd0a","v":1,"via":"run"}
@zackees

zackees commented Oct 11, 2026

Copy link
Copy Markdown
Member Author

Heads up: master pinned Rust 1.99.0, which soldr does not support, so Tier 2 / local-gate tier2-linux failed with "Could not find toolchain '1.99.0'". That was a repo bug, not this change. It is fixed in #185: the toolchain is pinned to 1.98.1 (the version soldr supports) and lint now enforces it, so branches still on 1.99.0 would fail lint. I rebased this branch onto master (no conflicts, commits unchanged), new head 663117b. Please run git fetch && git reset --hard origin/infra/sanitizer-workflow (or pull --rebase) before pushing again.

@zackees
zackees force-pushed the infra/sanitizer-workflow branch from c468e75 to 663117b Compare October 11, 2026 02:54
…_LIBOBS=ON

rustup's auto-install of rust-toolchain.toml is deprecated (rust-lang/rustup#4836)
and was what broke Tier 2 after the 1.99.0 pin (#180); install it explicitly,
as the Tier 2 image now does (#185).

Refs #143

Local-Gate: v1 tree=cf745e8b9398beee80d989502785c338f51992bc secs=93 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791687772,"gate":"rust/all/fmt","host":"linux-x86_64","key":"9c48a41145f4708d98a900d74ec2ecf4c58436ff012a23d08cd98e76fd12036f","lane":"lint","parents":["d6e212fb5c0f578581356f8f5850a20ba9e38890"],"secs":17,"stamp":"1a34a829bd3c4e83d6c4d4f45de6bb20","tree":"cf745e8b9398beee80d989502785c338f51992bc","v":1,"via":"run"}
Ci-Attestation: {"at":1791687772,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"9c48a41145f4708d98a900d74ec2ecf4c58436ff012a23d08cd98e76fd12036f","lane":"lint","parents":["d6e212fb5c0f578581356f8f5850a20ba9e38890"],"secs":17,"stamp":"354e69df08751212ba17cbc1a14bf4be","tree":"cf745e8b9398beee80d989502785c338f51992bc","v":1,"via":"run"}
Ci-Attestation: {"at":1791687772,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"7a8e339c11cfe3331cbc43e10651bae59647e856536b7bccf7ca151f6ec927ea","lane":"rust-test","parents":["d6e212fb5c0f578581356f8f5850a20ba9e38890"],"secs":41,"stamp":"2e69978320c00db4ae2aa7918b6add44","tree":"cf745e8b9398beee80d989502785c338f51992bc","v":1,"via":"run"}
Ci-Attestation: {"at":1791687772,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"9fc9f5fb384b754a913b3b9656abc68e70a3022f42e3eaf01e5ba966fcdfeafb","lane":"tier2-linux","parents":["d6e212fb5c0f578581356f8f5850a20ba9e38890"],"secs":34,"stamp":"3719087a0c66b49db58d7d9ba6fce886","tree":"cf745e8b9398beee80d989502785c338f51992bc","v":1,"via":"run"}
@zackees
zackees merged commit e226c3d into master Oct 11, 2026
27 checks passed
@zackees
zackees deleted the infra/sanitizer-workflow branch October 26, 2026 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant