Skip to content

Run cargo careful and sanitizers in CI - #20

Merged
tanglearncode merged 1 commit into
mainfrom
ci/ub-checks
Sep 13, 2026
Merged

tanglearncode merged 1 commit into
mainfrom
ci/ub-checks

Conversation

@tanglearncode

@tanglearncode tanglearncode commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Adds CI jobs that look for undefined behaviour while the real patching runs. Miri cannot run shimforge.

  • cargo careful on Linux, Windows and macOS
  • AddressSanitizer and ThreadSanitizer on x86_64 Linux

Notes:

  • One unit test leaks on purpose after a failed patch write. scripts/lsan-suppressions.txt ignores that leak only.
  • cargo careful skips the macros crate, because it cannot start that test binary.
  • The jobs pass -Znext-solver=coherence for now. It can be removed after Check borrowed inputs on the declared signature #19.

Trial run: https://github.com/XTSoftwareLabs/shimforge/actions/runs/34746405672

Miri cannot run shimforge, because it rewrites machine code at run time.
These jobs check the unsafe code while the real patching runs instead, with
the tools crossbeam uses for the same purpose:

- cargo careful on Linux, Windows and macOS, which rebuilds std with debug
  assertions and runs with -Z randomize-layout.
- AddressSanitizer and ThreadSanitizer on x86_64 Linux, through the
  x86_64-unknown-linux-gnuasan and gnutsan targets; ThreadSanitizer rebuilds
  std with -Z build-std.

Each job runs the shimforge test suite with one test thread, then
tests/parallel.rs with eight. Builds stay unoptimized, unlike crossbeam's,
because shimforge needs opt-level 0.

A trial on nightly-2026-08-15 found no memory errors, data races or failed
std preconditions. It needed three adjustments, all applied here:

- LeakSanitizer reports the route entry that routing::install_replacement
  keeps on purpose after a failed patch write. One unit test injects that
  failure, and scripts/lsan-suppressions.txt suppresses leaks from that test
  only. The job finds llvm-symbolizer so the suppression can match.
- cargo careful cannot start the shimforge-macros test binary, which links
  std dynamically, so the job tests the shimforge package only.
- Nightlies since 2026-08-22 use the next-generation trait solver, which
  rejects the current mock! signature check. The jobs pin nightly-2026-09-12
  and pass -Znext-solver=coherence until that check is changed.

The jobs are not required checks yet; that can only be set once this
workflow is on main.
@tanglearncode
tanglearncode merged commit 6f59f72 into main Sep 13, 2026
12 checks passed
@tanglearncode
tanglearncode deleted the ci/ub-checks branch September 14, 2026 03:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant