Out of approximately 80 crates, two fails to build with RUSTFLAGS=-Zsanitizer=address. I get about 3 results on google when I search for "Interceptors are not working". Should I be doing something more than setting RUSTFLAGS=-Zsanitizer-address?
I tried setting export DYLD_INSERT_LIBRARIES=... in the terminal, but no difference.
==39627==ERROR: Interceptors are not working. This may be because AddressSanitizer is loaded too late (e.g. via dlopen). Please launch the executable with:
==39628==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/niklasdusenlund/.rustup/toolchains/1.87.0-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/librustc-stable_rt.asan.dylib
"interceptors not installed" && 0
DYLD_INSERT_LIBRARIES=/Users/niklasdusenlund/.rustup/toolchains/1.87.0-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/librustc-stable_rt.asan.dylib
"interceptors not installed" && 0
error: could not compile `prost` (lib)
Caused by:
process didn't exit successfully: `/Users/niklasdusenlund/.rustup/toolchains/1.87.0-aarch64-apple-darwin/bin/rustc --crate-name prost --edition=2021 /Users/niklasdusenlund/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/prost-0.13.1/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=172 --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -C split-debuginfo=unpacked --cfg 'feature="derive"' --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values("default", "derive", "no-recursion-limit", "prost-derive", "std"))' -C metadata=43c4d3b68de541fe -C extra-filename=-2275d8bc251632e5 --out-dir /Users/niklasdusenlund/projects/shift/bitbox02-firmware/build-build-noasan/src/rust/fw/debug/deps -L dependency=/Users/niklasdusenlund/projects/shift/bitbox02-firmware/build-build-noasan/src/rust/fw/debug/deps --extern 'noprelude:alloc=/Users/niklasdusenlund/projects/shift/bitbox02-firmware/build-build-noasan/src/rust/fw/debug/deps/liballoc-dd93ab5c38984109.rmeta' --extern bytes=/Users/niklasdusenlund/projects/shift/bitbox02-firmware/build-build-noasan/src/rust/fw/debug/deps/libbytes-75fbfbad5c31e880.rmeta --extern 'noprelude:compiler_builtins=/Users/niklasdusenlund/projects/shift/bitbox02-firmware/build-build-noasan/src/rust/fw/debug/deps/libcompiler_builtins-b757677c739bed6f.rmeta' --extern 'noprelude:core=/Users/niklasdusenlund/projects/shift/bitbox02-firmware/build-build-noasan/src/rust/fw/debug/deps/libcore-29bdb673044c6dfd.rmeta' --extern 'noprelude:panic_unwind=/Users/niklasdusenlund/projects/shift/bitbox02-firmware/build-build-noasan/src/rust/fw/debug/deps/libpanic_unwind-5acdb8dd041ba86d.rmeta' --extern 'noprelude:proc_macro=/Users/niklasdusenlund/projects/shift/bitbox02-firmware/build-build-noasan/src/rust/fw/debug/deps/libproc_macro-63f980506b7530e5.rmeta' --extern prost_derive=/Users/niklasdusenlund/projects/shift/bitbox02-firmware/build-build-noasan/src/rust/fw/debug/deps/libprost_derive-6d586cdf098b08cb.dylib --extern 'noprelude:std=/Users/niklasdusenlund/projects/shift/bitbox02-firmware/build-build-noasan/src/rust/fw/debug/deps/libstd-38410e73fa035e8d.rmeta' -Z unstable-options --cap-lints allow -Zsanitizer=address` (signal: 6, SIGABRT: process abort signal)
warning: build failed, waiting for other jobs to finish...
error: could not compile `zeroize` (lib)
Caused by:
process didn't exit successfully: `/Users/niklasdusenlund/.rustup/toolchains/1.87.0-aarch64-apple-darwin/bin/rustc --crate-name zeroize --edition=2021 /Users/niklasdusenlund/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/zeroize-1.8.1/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=172 --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -C split-debuginfo=unpacked --cfg 'feature="alloc"' --cfg 'feature="default"' --cfg 'feature="zeroize_derive"' --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values("aarch64", "alloc", "default", "derive", "serde", "simd", "std", "zeroize_derive"))' -C metadata=0158f9fd23e668c5 -C extra-filename=-0563c42cb53388c1 --out-dir /Users/niklasdusenlund/projects/shift/bitbox02-firmware/build-build-noasan/src/rust/fw/debug/deps -L dependency=/Users/niklasdusenlund/projects/shift/bitbox02-firmware/build-build-noasan/src/rust/fw/debug/deps --extern 'noprelude:alloc=/Users/niklasdusenlund/projects/shift/bitbox02-firmware/build-build-noasan/src/rust/fw/debug/deps/liballoc-dd93ab5c38984109.rmeta' --extern 'noprelude:compiler_builtins=/Users/niklasdusenlund/projects/shift/bitbox02-firmware/build-build-noasan/src/rust/fw/debug/deps/libcompiler_builtins-b757677c739bed6f.rmeta' --extern 'noprelude:core=/Users/niklasdusenlund/projects/shift/bitbox02-firmware/build-build-noasan/src/rust/fw/debug/deps/libcore-29bdb673044c6dfd.rmeta' --extern 'noprelude:panic_unwind=/Users/niklasdusenlund/projects/shift/bitbox02-firmware/build-build-noasan/src/rust/fw/debug/deps/libpanic_unwind-5acdb8dd041ba86d.rmeta' --extern 'noprelude:proc_macro=/Users/niklasdusenlund/projects/shift/bitbox02-firmware/build-build-noasan/src/rust/fw/debug/deps/libproc_macro-63f980506b7530e5.rmeta' --extern 'noprelude:std=/Users/niklasdusenlund/projects/shift/bitbox02-firmware/build-build-noasan/src/rust/fw/debug/deps/libstd-38410e73fa035e8d.rmeta' --extern zeroize_derive=/Users/niklasdusenlund/projects/shift/bitbox02-firmware/build-build-noasan/src/rust/fw/debug/deps/libzeroize_derive-14f513d216114154.dylib -Z unstable-options --cap-lints allow -Zsanitizer=address` (signal: 6, SIGABRT: process abort signal)
I'm also setting -Zbuild-std so that stdlibs are built with asan.
It's not clear what exactly your distinct, separate errors are. The way you've pasted them it looks like ASAN is running during the compilation step which causes compilation to fail. if you did export DYLD_INSERT_LIBRARIES="..." then re-ran your build command, don't do that. It would likely explain why the crates are failing to compile -- if the ASAN runtime library doesn't intercept the functions correctly then it will cause an abort, and your build commands are exiting with a SIGABRT.
At any rate, the interceptor error is caused by ASAN doing runtime hooking ("interceptors") of various functions (like memcpy, malloc, free, etc.) and when the ASAN runtime executes it checks to see if the hooks successfully applied.
It looks like you could set the ASAN_OPTIONS="verify_interceptors=0" env var to disable this check, but ASAN will likely not functionally work as expected. Why the interceptors are failing I'm unsure -- that's an ASAN runtime library issue though and not a Rust issue. The binary was linked correctly with ASAN and likely has ASAN instrumentation (verify with nm -gD <target_binary> | grep __asan).
Did you somehow build proc macros or build scripts with ASAN? As opposed to just the program? It kind of looks like it to me.
Another thing to try if that leads nowhere: can you reproduce on Linux (in a VM presumably)? I don't know much about Mac, so it could be worth checking if it is a Mac specific issue.
Edit: Nope! Try passing --target explicitly as if you were cross compiling. I think that will fix it. But the diagnostics for this being needed is poor.
I think the compiler should give a useful error here. Rust does that in many other places. The current result is not a good user experience, and should really be improved before this is stabilised.