Skip to content

error: mixing -Zsanitizer will cause an ABI mismatch - when running doctests #146465

@gendx

Description

@gendx

I tried these commands (following the sanitizer tutorial) on the code at https://github.com/gendx/paralight/tree/791d03a794b3c2089186979687065d107532fc93:

export RUSTFLAGS="-Zsanitizer=thread"
export RUSTDOCFLAGS="-Zsanitizer=thread"
cargo +nightly test --release -Zbuild-std --target=x86_64-unknown-linux-gnu

I expected to see this happen: tests should run with thread sanitizer enabled.

Instead, this happened: regular tests ran fine, but doc tests failed to compile with the following error. In particular, "help: set -Zsanitizer=thread in this crate" is strange given that I've set RUSTDOCFLAGS="-Zsanitizer=thread".

error: mixing `-Zsanitizer` will cause an ABI mismatch in crate `paralight`
 --> src/lib.rs:9:1
  |
9 | #![doc = include_str!("../README.md")]
  | ^
  |
  = help: the `-Zsanitizer` flag modifies the ABI so Rust crates compiled with different values of this flag cannot be used together safely
  = note: unset `-Zsanitizer` in this crate is incompatible with `-Zsanitizer=thread` in dependency `std`
  = help: set `-Zsanitizer=thread` in this crate or unset `-Zsanitizer` in `std`
  = help: if you are sure this will not cause problems, you may use `-Cunsafe-allow-abi-mismatch=sanitizer` to silence this error

I suspect this might be related to #138736 or more broadly the work tracked in #138453.

Meta

rustc +nightly --version --verbose:

rustc 1.91.0-nightly (5eda692e7 2025-09-11)
binary: rustc
commit-hash: 5eda692e73f37dcbe2437ce878db7bb71f323e74
commit-date: 2025-09-11
host: x86_64-unknown-linux-gnu
release: 1.91.0-nightly
LLVM version: 21.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-doctestsArea: Documentation tests, run by rustdocA-sanitizersArea: Sanitizers for correctness and code qualityC-bugCategory: This is a bug.F-target_modifiers`#![feature(target_modifiers)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions