Questions tagged [address-sanitizer]

AddressSanitizer (ASAN) is a fast memory error detector for issues such as out-of-bounds access and more.

AddressSanitizer (ASAN) is a fast memory error detector and consists of compile time instrumentation and a runtime library.

See also:

530 questions
11
votes
2 answers

Get line numbers with AddressSanitizer output?

I'm trying to get AddressSanitizer to produce line numbers in its stack traces. I've tried on by a Mac and a Fedora 19 system and had similar results. Here is a simple program: #include #include int main(int argc,char **argv) { …
vy32
  • 28,461
  • 37
  • 122
  • 246
10
votes
1 answer

OpenCL usable when compiling host application with Address Sanitizer

I'm debugging a crash of my OpenCL application. I attempted to use ASan to pin down where the problem originates. But then I discovered that I enable ASan when recompiling, my application cannot find any OpenCL devices. Simply adding…
Mary Chang
  • 865
  • 6
  • 25
10
votes
3 answers

Mac OS: Leaks Sanitizer

Mac OS X Sierra 10.13 I do as wrote here https://clang.llvm.org/docs/LeakSanitizer.html I.e. created the small application with memory leak #include void *p; int main() { p = malloc(7); p = 0; // The memory is leaked here. return…
ZedZip
  • 5,794
  • 15
  • 66
  • 119
10
votes
1 answer

C++ AddressSanitizer with CMakeLists.txt results in asan errors

Trying to use the AddressSanitizer tool (ASan) on my C++ project, I get a very verbose output full of undefined reference to '__asan_report_store8' and undefined reference to '__asan_report_load8', and others like __asan_stack_malloc_2. My project…
BoltzmannBrain
  • 5,082
  • 11
  • 46
  • 79
10
votes
1 answer

Get location of libasan from gcc/clang

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…
Edward Z. Yang
  • 26,325
  • 16
  • 80
  • 110
10
votes
1 answer

How to enable address sanitizer for multiple C++ binaries

I am working on a product that is composed of multiple C++ executables and libraries that have various dependencies on one another. I am building them all with GCC and -fsanitize-address. From what I understand, if I want to use address sanitizer…
Perennialista
  • 1,083
  • 2
  • 12
  • 22
10
votes
2 answers

Why is "Enable Address Sanitizer" disabled in Xcode 7?

I read about the Runtime Sanitization in the Apple docs in the new Xcode 7, so I looked for it, and found that it's disabled. I'm using Xcode 7 GM seed. When I go into the Run action of the scheme > Diagnostics tab, the Enable Address Sanitizer…
Sheamus
  • 6,506
  • 3
  • 35
  • 61
9
votes
1 answer

How to compile Clang with sanitizers

I just compiled Clang using CMake and then tried running a sanitizer (with clang -fsanitize=address), but got: /usr/bin/ld: cannot find /9.0.0/lib/linux/libclang_rt.asan-x86_64.a: No such file or directory I then went to the "How to…
anol
  • 8,264
  • 3
  • 34
  • 78
9
votes
2 answers

AddressSanitizer Suppression

I am trying to suppress a warning from the address sanitizer in clang/gcc My source file looks like this: int foo(){ double bar[] = {7,8}; return bar[3]; } int main(){ return foo(); } and obviously there is an overflow at line 3. the…
user1928546
  • 143
  • 1
  • 1
  • 5
9
votes
1 answer

Which of the three mutually exclusive Clang sanitizers should I default to?

Clang has a number of sanitizers that enable runtime checks for questionable behavior. Unfortunately, they can't all be enabled at once. It is not possible to combine more than one of the -fsanitize=address, -fsanitize=thread, and…
Maxpm
  • 24,113
  • 33
  • 111
  • 170
9
votes
2 answers

Why address sanitizer doesn't work for bss global overflow?

What I have done. Test1 1 #include 2 3 int test[16]; …
Alex Hoppus
  • 3,821
  • 4
  • 28
  • 47
8
votes
1 answer

Asan : Issue with asan library loading

In our build system we have recently integrated ASAN tool (adding -fsanitize=address) to CFLAGS & also while linking , creating library .so files. Note:- We are using GCC 6.3 compiler. We are able to successfully build our code. But while running it…
santosh
  • 421
  • 1
  • 6
  • 14
8
votes
2 answers

How to make AddressSanitizer not check third party libraries

I am working on a C++ cmake project. Apart from my own source code, my project uses a lot of third party libraries. So, I am using shared libraries (with .so extension) which are present in /usr/local/lib and for some the code is present in…
mascot
  • 141
  • 2
  • 9
8
votes
1 answer

valgrind, gcc 6.2.0 and "-fsanitize=address"

Recently, when compiling with '-fsanitize=address' I am getting an execution exception when running an application with valgrind namely "ASan runtime does not come first in initial library list" I am a little clueless what valgrind actually does.…
Frank-Rene Schäfer
  • 3,182
  • 27
  • 51
8
votes
3 answers

How can I determine if UBSAN has been compiled in using clang or gcc?

We use the following code to determine if -fsanitize=address has been specified at compile time for clang and gcc. How do we determine if -fsanitize=undefined has been specified? bool isSanitized = false; #if defined(__has_feature) #if…
1 2
3
35 36