address-sanitizer

How to detect if building with address sanitizer when building with gcc 4.8?

▼魔方 西西 提交于 2019-12-23 07:25:53
问题 I'm working on a program written in C that I occasionally build with address sanitizer, basically to catch bugs. The program prints a banner in the logs when it starts up with info such as: who built it, the branch it was built on, compiler etc. I was thinking it would be nice to also spell out if the binary was built using address sanitizer. I know there's __has_feature(address_sanitizer), but that only works for clang. I tried the following simple program: #include <stdio.h> int main() {

How do I find why the virtual memory foot print continuously grows with this daemon?

跟風遠走 提交于 2019-12-23 05:04:43
问题 I created a daemon which I use as a proxy to the Cassandra database. I call it snapdbproxy as it proxies my CQL commands from my other servers and tools. Whenever I access that tool, it creates a new thread, manages various CQL commands, and then I cleanly exit the thread once the connection is lost. Looking at the memory footprint, it grows really fast (the most active systems quickly reach Gb of virtual memory and that makes use of some swap memory which grows constantly.) On startup, it is

AddressSanitizer / LeakSanitizer Error with -lsupc++ and -stdlib=libc++ on a never called virtual function that writes to a stream

徘徊边缘 提交于 2019-12-22 17:57:22
问题 The following code throws an AddressSanitizer Error when compiled on Debian Jessie with clang 3.5. It appears to be related to the combination of linked libraries, but i have not been able to find something similar on the internet. Reproduction of the Error Invocation: clang++ -stdlib=libc++ -lc++abi -fsanitize=address,vptr sample.cpp -lsupc++ -o sample //sample.cpp #include <iostream> class Foo { virtual void bar() { std::cerr << std::endl; } public: virtual ~Foo() { } }; int main() { Foo

How to generate core dump on AddressSanitizer error

≯℡__Kan透↙ 提交于 2019-12-21 19:56:46
问题 I compiled my code like this to enable Asan: g++ -O0 -g -fsanitize=address -fno-omit-frame-pointer but it never generates a core dump so that I can later examine the details of the error. How can I generate it? 回答1: You need to set environment variable to request coredumps export ASAN_OPTIONS=abort_on_error=1 This should really be default but due to historic reasons ASan just exits with non-zero error code instead. On 64-bit systems you might need to add export ASAN_OPTIONS=...:disable

How do you enable Clang Address Sanitizer in Xcode?

。_饼干妹妹 提交于 2019-12-20 03:09:07
问题 As announced at WWDC 2015, Clang Address Sanitizer is being brought to Xcode and OS X. Session 413: Advanced Debugging and the Address Sanitizer How do you enable Clang Address Sanitizer for your Xcode project? 回答1: Address Sanitizer has been added as a new feature in Xcode 7. Use the Runtime Sanitization > Enable Address Sanitizer flag in your scheme to enable the option. git will then shown this change to your .xcscheme file: enableAddressSanitizer = "YES" From the New Features in Xcode 7

address sanitizer won't work with bash on windows

强颜欢笑 提交于 2019-12-19 18:47:34
问题 Currently running llvm, clang, clang-format, and clang-modernize on Ubuntu Bash on Windows. I would like to use the set of sanitize tools released by google including address, memory, and thread sanitize. None of the fsanitize options seem to work. Here is the code sample for ASAN: #include <stdlib.h> int main() { char *x = (char *)malloc(10 * sizeof(char *)); free(x); return x[5];// purposely accessing deallocated memory } Here is the clang call in bash on windows: $clang++-3.5 -fsanitize

MinGW-w64's gcc and Address Sanitizer

烂漫一生 提交于 2019-12-18 12:18:19
问题 Installing MinGW-w64 5.1 I find -fsanitize=address is available. It compiles fine, and when it starts linking I get thousands of: undefined reference to '__asan_report_load1' undefined reference to '__asan_report_load4' I googled and found libasan referenced various places, but also comments that when you include -fsanitize=address it automatically includes that library for linking. I searched the MinGW-w64 5.1 install dirctory for "asan" and it was not found anywhere. What do I need to add

clang vs gcc behavioral difference with AddressSanitizer

五迷三道 提交于 2019-12-11 17:58:17
问题 I have a sample code with memory leaks. Though clang displays the leak correctly, I am unable to achieve the same with gcc. gcc version I am using is 4.8.5-39 Code: #include <stdlib.h> void *p; int main() { p = malloc(7); p = 0; // The memory is leaked here. return 0; } CLANG: clang -fsanitize=address -g memory-leak.c ; ASAN_OPTIONS=detect_leaks=1 ./a.out ================================================================= ==15543==ERROR: LeakSanitizer: detected memory leaks Direct leak of 7

Get location of libasan from gcc/clang

删除回忆录丶 提交于 2019-12-11 09:53:32
问题 When I compile with -fsanitize=address , GCC/Clang implicitly make use of an ASAN dynamic library which provides runtime support for ASAN. If your built library is dynamically loaded by another application, it is necessary to set LD_PRELOAD to include this dynamic library, so that it gets run at application start up time. It is often not obvious which copy of libasan.so GCC/Clang expects to use, because there may be multiple copies of ASAN on your system (if you have multiple compilers

Undefined symbol error with -static-libasan

帅比萌擦擦* 提交于 2019-12-11 03:28:53
问题 I use address sanitizer to sanitize my application, Which is linked with SOCI. But that prompt followijg error message while using with Oracle. ./SociUT: symbol lookup error: /home/testhome/libs/libsoci_oracle.d.so.1.4.18: undefined symbol: __asan_unregister_globals Here is the build output of aplication /home/rel/GCC/asan-gcc-4.9.3/bc0232/bin/g++ -std=c++11 -g3 -static-libasan -fsanitize=address -fno-omit-frame-pointer -L/home/mt_1/4/4.7.c/build/bc0397/tech/MB/link/API/63 -L/usr/lib64 -L/usr