Description
hwasan (hardware-assisted asan) is a complementary tool to the classical asan.
Both tools can catch an overlapping set of memory issues, but each has strengths and weaknesses. HWASAN uses memory tagging (allocated memory gets randomly assigned a "color tag", when access happens through a pointer of different color, a failure is reported). ASAN uses buffer zones before and after allocated memory and detects invalid accesses into these zones and into recently freed memory.
HWASAN is designed to have much smaller memory overhead, with the original idea being that it could be turned on by default in production (on mobile Android devices).
Currently, in LLVM 11, HWASAN does not work to compile Dispatch. It would be nice if Clang 12 did work. Issue needs to be reported.
https://travis-ci.com/github/apache/qpid-dispatch/jobs/492330729#L1859
[ 35%] Building C object src/CMakeFiles/qpid-dispatch.dir/router_core/agent.c.o fatal error: error in backend: Unexpected instruction PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script. Stack dump: 0. Program arguments: /usr/bin/clang-11 -g -fno-omit-frame-pointer -fsanitize=hwaddress,undefined -std=gnu99 -O2 -g -fPIC -Wall -Wpedantic -Wno-gnu-statement-expression -fcolor-diagnostics -Werror -Dqpid_dispatch_EXPORTS -I/home/travis/build/apache/qpid-dispatch/include -I/home/travis/build/apache/qpid-dispatch/build/include -I/home/travis/build/apache/qpid-dispatch/install/include -I/usr/include/python3.8 -I/home/travis/build/apache/qpid-dispatch/src -I/home/travis/build/apache/qpid-dispatch/src/router_core -I/home/travis/build/apache/qpid-dispatch/build/src -DQD_MEMORY_DEBUG -DNDEBUG -c -o CMakeFiles/qpid-dispatch.dir/router_config.c.o /home/travis/build/apache/qpid-dispatch/src/router_config.c 1. <eof> parser at end of file 2. Per-module optimization passes 3. Running pass 'Function Pass Manager' on module '/home/travis/build/apache/qpid-dispatch/src/router_config.c'. 4. Running pass 'HWAddressSanitizer' on function '@qdi_router_configure_body' #0 0x00007fa2755b542f llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/lib/x86_64-linux-gnu/libLLVM-11.so.1+0xaa642f) #1 0x00007fa2755b3790 llvm::sys::RunSignalHandlers() (/lib/x86_64-linux-gnu/libLLVM-11.so.1+0xaa4790) #2 0x00007fa2755b4b7d llvm::sys::CleanupOnSignal(unsigned long) (/lib/x86_64-linux-gnu/libLLVM-11.so.1+0xaa5b7d) #3 0x00007fa2754fcb0a (/lib/x86_64-linux-gnu/libLLVM-11.so.1+0x9edb0a) #4 0x00007fa2754fcaab (/lib/x86_64-linux-gnu/libLLVM-11.so.1+0x9edaab) #5 0x00007fa2755b025e (/lib/x86_64-linux-gnu/libLLVM-11.so.1+0xaa125e) #6 0x0000000000412932 (/usr/bin/clang-11+0x412932) #7 0x00007fa275508b6f llvm::report_fatal_error(llvm::Twine const&, bool) (/lib/x86_64-linux-gnu/libLLVM-11.so.1+0x9f9b6f) #8 0x00007fa275508a48 (/lib/x86_64-linux-gnu/libLLVM-11.so.1+0x9f9a48) #9 0x00007fa275fa050f (/lib/x86_64-linux-gnu/libLLVM-11.so.1+0x149150f) #10 0x00007fa2756c4579 llvm::FPPassManager::runOnFunction(llvm::Function&) (/lib/x86_64-linux-gnu/libLLVM-11.so.1+0xbb5579) #11 0x00007fa2756c9b23 llvm::FPPassManager::runOnModule(llvm::Module&) (/lib/x86_64-linux-gnu/libLLVM-11.so.1+0xbbab23) #12 0x00007fa2756c4b90 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/lib/x86_64-linux-gnu/libLLVM-11.so.1+0xbb5b90) #13 0x00007fa27b034120 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout const&, llvm::Module*, clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) (/lib/x86_64-linux-gnu/libclang-cpp.so.11+0x1581120) #14 0x00007fa27b2f2076 (/lib/x86_64-linux-gnu/libclang-cpp.so.11+0x183f076) #15 0x00007fa27a3bd003 clang::ParseAST(clang::Sema&, bool, bool) (/lib/x86_64-linux-gnu/libclang-cpp.so.11+0x90a003) #16 0x00007fa27b9875c8 clang::FrontendAction::Execute() (/lib/x86_64-linux-gnu/libclang-cpp.so.11+0x1ed45c8) #17 0x00007fa27b93d8c1 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/lib/x86_64-linux-gnu/libclang-cpp.so.11+0x1e8a8c1) #18 0x00007fa27b9ecf50 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/lib/x86_64-linux-gnu/libclang-cpp.so.11+0x1f39f50) #19 0x00000000004125ff cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/bin/clang-11+0x4125ff) #20 0x0000000000410a3e (/usr/bin/clang-11+0x410a3e) #21 0x00007fa27b671992 (/lib/x86_64-linux-gnu/libclang-cpp.so.11+0x1bbe992) #22 0x00007fa2754fca8d llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/lib/x86_64-linux-gnu/libLLVM-11.so.1+0x9eda8d) #23 0x00007fa27b670ebf clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const (/lib/x86_64-linux-gnu/libclang-cpp.so.11+0x1bbdebf) #24 0x00007fa27b648ccf clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const (/lib/x86_64-linux-gnu/libclang-cpp.so.11+0x1b95ccf) #25 0x00007fa27b648e77 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const (/lib/x86_64-linux-gnu/libclang-cpp.so.11+0x1b95e77) #26 0x00007fa27b65c9cc clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) (/lib/x86_64-linux-gnu/libclang-cpp.so.11+0x1ba99cc) #27 0x00000000004104e3 main (/usr/bin/clang-11+0x4104e3) #28 0x00007fa2745f70b3 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b3) #29 0x000000000040dcde _start (/usr/bin/clang-11+0x40dcde) clang: error: clang frontend command failed with exit code 70 (use -v to see invocation) Ubuntu clang version 11.0.0-2~ubuntu20.04.1 Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/bin clang: note: diagnostic msg: ******************** PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT: Preprocessed source(s) and associated run script(s) are located at: clang: note: diagnostic msg: /tmp/router_config-29e8f5.c clang: note: diagnostic msg: /tmp/router_config-29e8f5.sh clang: note: diagnostic msg: ******************** make[2]: *** [src/CMakeFiles/qpid-dispatch.dir/build.make:535: src/CMakeFiles/qpid-dispatch.dir/router_config.c.o] Error 70 make[2]: *** Waiting for unfinished jobs.... make[1]: *** [CMakeFiles/Makefile2:1053: src/CMakeFiles/qpid-dispatch.dir/all] Error 2 make: *** [Makefile:141: all] Error 2 The command "make -j $NPROC" failed and exited with 2 during . Your build has been stopped.