Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cargo test could not load address sanitizer correctly #9693

Closed
psionic12 opened this issue Jul 15, 2021 · 1 comment
Closed

Cargo test could not load address sanitizer correctly #9693

psionic12 opened this issue Jul 15, 2021 · 1 comment
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`

Comments

@psionic12
Copy link

psionic12 commented Jul 15, 2021

Cargo could not load address sanitizer correctly when testing, it reported as below:

==45307==ERROR: Interceptors are not working. This may be because AddressSanitizer is loaded too late (e.g. via dlopen). Please launch the executable with:
DYLD_INSERT_LIBRARIES=/Users/psionic12/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc-nightly_rt.asan.dylib

I introduced asan by adding a config.toml:

[build]
rustflags = ["-Zsanitizer=address"]

and all the test codes are in the test folder, not in src folder.

I'm not very clear how does cargo test works, I tried to do as the error suggested, but I can't find the executable of my tests, does cargo test executable even exists?

@psionic12 psionic12 added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label Jul 15, 2021
@ehuss
Copy link
Contributor

ehuss commented Jul 19, 2021

Thanks for the report! I believe you should be able to work around the issue by passing --target x86_64-apple-darwin (it's hard to say without seeing the full error). The problem is that the sanitizer flag is being passed to host dependencies, like proc macros.

Assuming that's the issue, I'm going to close this as a duplicate of rust-lang/rust#63986 and #3739. If you have further issues with using sanitizers, I would recommend filing issues at https://github.com/rust-lang/rust/issues as Cargo doesn't really have any interaction with them.

@ehuss ehuss closed this as completed Jul 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
Projects
None yet
Development

No branches or pull requests

2 participants