I have been trying to use Clang's address code sanitizer, but the linker will not have it. The linker may be "ld", though my CMAKE settings assure me that clang is the linker.
Added -fsanitize=address
to compiler and linker flags.
Error:
Undefined symbols for architecture x86_64: ___asan_after_dynamic_init ... ___asan_before_dynamic_init ... etc. ld: symbol(s) not found for architecture x86_64 <<<< **suspicious** clang: error: linker command failed with exit code 1 (use -v to see invocation)
cmake: 3.7.1
CMAKE_CXX_COMPILER = /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ (redirects to clang)
Introduction. AddressSanitizer is a fast memory error detector. It consists of a compiler instrumentation module and a run-time library. The tool can detect the following types of bugs: Out-of-bounds accesses to heap, stack and globals.
AddressSanitizer dedicates one-eighth of the virtual address space to its shadow memory and uses a direct mapping with a scale and offset to translate an applica- tion address to its corresponding shadow address.
Address Sanitizer is a tool developed by Google detect memory access error such as use-after-free and memory leaks. It is built into GCC versions >= 4.8 and can be used on both C and C++ codes.
AddressSanitizer can optionally detect stack use after return problems. This is available by default, or explicitly ( -fsanitize-address-use-after-return=runtime ). To disable this check at runtime, set the environment variable ASAN_OPTIONS=detect_stack_use_after_return=0 .
Solution from here
Pass the -fsanitize=address flag to the linker as well as the compiler.
-DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With