Skip to content

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

Closed

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

Activity

  1. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Sep 12, 2025
  2. iorizu commented on Sep 12, 2025

    @iorizu
    Contributor

    The CI for the crate triomphe fails for this exact reason also. I've tested various versions and the one that introduces the failure is nightly 2025-09-06 (rustc 6c699a372). That version contains #138736.

    $ git log --first-parent --oneline af00ff2ce..6c699a372
    6c699a37235 Auto merge of #146255 - fmease:rollup-1v0kp8i, r=fmease
    99317ef14d0 Auto merge of #146121 - Muscraft:filter-suggestion-parts, r=petrochenkov
    9cd272dc853 Auto merge of #146044 - estebank:issue-88727, r=chenyukang
    c559c4a7418 Auto merge of #146224 - tgross35:rollup-1bgjms3, r=tgross35
    ad85bc524b1 Auto merge of #144737 - petrochenkov:extprelcache, r=davidtwco
    91edc3ebccc Auto merge of #146218 - flip1995:clippy-subtree-update, r=Manishearth
    b3cfb8faf84 Auto merge of #138736 - azhogin:azhogin/sanitizers-target-modificators, r=rcvalle
    

    af00ff2ce is the commit hash of nightly 2025-09-05.

    That PR (and the error) says that adding -Cunsafe-allow-abi-mismatch=sanitizer will fix the issue, but it feels like that shouldn't be necessary. Assuming that the issue is that the std lib is being built with -Zsanitizer=thread set and the doctests are being built with -Zsanitizer unset, shouldn't it be the case that the RUSTDOCFLAGS='-Zsanitizer=thread' env variables force the tests to be built with the sanitizer option set? If not, that feels like a bug.

  3. Darksonn commented on Sep 12, 2025

    @Darksonn
    Member

    Similar to #144521. Probably has a similar to fix to #144523.

  4. Darksonn commented on Sep 12, 2025

    @Darksonn
    Member
  5. added
    A-sanitizersArea: Sanitizers for correctness and code quality
    A-doctestsArea: Documentation tests, run by rustdoc
    on Sep 12, 2025
  6. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Sep 12, 2025
  7. 25 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions