You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Running sanitizer tests fails with mixed ABI errors #147394
error: mixing `-Zsanitizer` will cause an ABI mismatch incrate `hashlink`
|
= 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=memory` in dependency `core`
= help: set `-Zsanitizer=memory` in this crate or unset `-Zsanitizer` in `core`
= help:if you are sure this will not cause problems, you may use `-Cunsafe-allow-abi-mismatch=sanitizer` to silence this error
Note that I already added the suppression option, but it doesn't seem to take effect here?
You're trying to use sanitizer=address but getting an error about sanitizer=memory? That's a transcription error or something is deeply wrong with your build environment.
Yeah, that's what it seems like to me. You should be able to pass --verbose to Cargo to see the exact flags being used. I usually also add -j1 so the output arrives in a simpler order. At least if you can see all the flags for the ASan build that should indicate if MSan crates are being pulled in from another build... Somehow.
RUSTFLAGS="-Z sanitizer=memory" cargo test -Z build-std --target=x86_64-unknown-linux-gnu
The trick is this note in the PR:
For now, we should mark all sanitizers as target modifiers except for these: AddressSanitizer, LeakSanitizer
And this diagnostic:
= note: unset `-Zsanitizer` in this crate is incompatible with `-Zsanitizer=memory` in dependency `std`
The problem is that to set compiler flags in doctests you need to set RUSTDOCFLAGS. This is a pretty classic footgun, and a number of my scripts have RUSTDOCFLAGS=$RUSTFLAGS to prevent this.
This also explains why adding -Cunsafe-allow-abi-mismatch=sanitizer to RUSTFLAGS doesn't help. This does though:
RUSTDOCFLAGS=-Cunsafe-allow-abi-mismatch=sanitizer RUSTFLAGS="-Z sanitizer=memory" cargo test -Z build-std --target=x86_64-unknown-linux-gnu
I led you astray. Using -Zbuild-std without --target makes Cargo rebuild the standard library but doesn't put it into cross-compilation mode, which leads to the RUSTFLAGS being applied to host builds (proc macros and build scripts) but they are still built against the precompiled sysroot.
AddressSanitizer supports partially-instrumented builds, and MemorySanitizer does not. These false positives are the outcome, and there are handful of closed issues on the tracker of people filing bugs against the standard library because the toolchain let them misconfigure a build and get a report that looks like a true positive, but isn't. You are using -Cunsafe-allow-abi-mismatch to bypass the check that was written to prevent this situation :p
Yes, if djc actually wants to run doctests, that would be #146465. I still think there is a diagnostic problem here, we shouldn't have diagnostics that lead to the confusion reported in the original issue description:
Note that I already added the suppression option, but it doesn't seem to take effect here?
Note that I already added the suppression option, but it doesn't seem to take effect here?
If the error is about a doctest (not enough context to tell because the error message you pasted doesn't show the line at which the error occurs), you should add the suppression option to RUSTDOCFLAGS, not RUSTFLAGS. Perhaps that's where the confusion is coming from?
Activity
djc commentedon Oct 6, 2025
I cannot reproduce this on my own ARM64 Linux server. This just works:
(I also tried the CI without
--target, and that still fails the same way as before.)saethlin commentedon Oct 14, 2025
You're trying to use sanitizer=address but getting an error about sanitizer=memory? That's a transcription error or something is deeply wrong with your build environment.
djc commentedon Oct 14, 2025
@saethlin thanks for having a look! If you look at the original CI run, it seems to be similar:
https://app.circleci.com/pipelines/github/djc/hashlink/189/workflows/58588dc4-d323-428f-a309-d950c5fa2b0f/jobs/180
Maybe it doesn't rebuild dependencies correctly, so that an earlier
sanitizer=addressbuild is reused when I run withsanitizer=memorylater?saethlin commentedon Oct 14, 2025
Yeah, that's what it seems like to me. You should be able to pass
--verboseto Cargo to see the exact flags being used. I usually also add-j1so the output arrives in a simpler order. At least if you can see all the flags for the ASan build that should indicate if MSan crates are being pulled in from another build... Somehow.saethlin commentedon Oct 14, 2025
I can repro locally. The fact that this only happens with doctests seems relevant.
saethlin commentedon Oct 14, 2025
Repros with an empty library crate. What in tarnation...
saethlin commentedon Oct 14, 2025
This bisects to #138736 but I think that PR just uncovered the problem
saethlin commentedon Oct 14, 2025
To repro, on an empty library crate run
The trick is this note in the PR:
And this diagnostic:
The problem is that to set compiler flags in doctests you need to set RUSTDOCFLAGS. This is a pretty classic footgun, and a number of my scripts have
RUSTDOCFLAGS=$RUSTFLAGSto prevent this.This also explains why adding
-Cunsafe-allow-abi-mismatch=sanitizerto RUSTFLAGS doesn't help. This does though:So this is a diagnostic problem.
8 remaining items
djc commentedon Oct 15, 2025
@saethlin thanks a lot for digging in! This allowed me to make some progress.
First, I still needed
-Cunsafe-allow-abi-mismatch=sanitizerinRUSTFLAGSas well, otherwise it complained aboutbuild_script_buildtargets.Second, I'm now getting this error:
Is this worth an issue against compiler-builtins? Or maybe there is a suppression mechanism somewhere...
saethlin commentedon Oct 15, 2025
I led you astray. Using
-Zbuild-stdwithout--targetmakes Cargo rebuild the standard library but doesn't put it into cross-compilation mode, which leads to the RUSTFLAGS being applied to host builds (proc macros and build scripts) but they are still built against the precompiled sysroot.AddressSanitizer supports partially-instrumented builds, and MemorySanitizer does not. These false positives are the outcome, and there are handful of closed issues on the tracker of people filing bugs against the standard library because the toolchain let them misconfigure a build and get a report that looks like a true positive, but isn't. You are using
-Cunsafe-allow-abi-mismatchto bypass the check that was written to prevent this situation :pdjc commentedon Oct 15, 2025
Thanks a lot! Was finally able to fix hashlink CI so we can get updates rolling again.
Thomasdezeeuw commentedon Oct 15, 2025
Seems like this is the same issue as #146465?
Anyone looking for a quick fix using
--all-targetsskips the tests for docs, so:Don't run doc tests with sanitizer
Don't run doc tests with sanitizer (#1908)
saethlin commentedon Oct 15, 2025
Yes, if djc actually wants to run doctests, that would be #146465. I still think there is a diagnostic problem here, we shouldn't have diagnostics that lead to the confusion reported in the original issue description:
gendx commentedon Oct 22, 2025
If the error is about a doctest (not enough context to tell because the error message you pasted doesn't show the line at which the error occurs), you should add the suppression option to
RUSTDOCFLAGS, notRUSTFLAGS. Perhaps that's where the confusion is coming from?saethlin commentedon Oct 22, 2025
That has already been mentioned in #147394 (comment) but be aware that GitHub is hiding most of this thread because of the backlinks.