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:

381 questions
59
votes
3 answers

How to use AddressSanitizer with GCC?

I'm trying to build my project with g++ -O0 -g -fsanitize=address -fno-omit-frame-pointer but get lots of errors like: /home/user/libs/opencv/include/opencv2/core/mat.hpp:715: undefined reference to `__asan_report_load8' How to compile project…
mrgloom
  • 15,245
  • 23
  • 126
  • 226
44
votes
6 answers

What's the proper way to enable AddressSanitizer in CMake that works in Xcode

I've added AddressSanitizer flag as follow: set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address") Everything builds and runs fine when using Unix Makefiles. The problem comes when generating the Xcode project, it just doesn't want to link…
ObjSal
  • 799
  • 1
  • 7
  • 16
38
votes
2 answers

Memory/Address Sanitizer vs Valgrind

I want some tool to diagnose use-after-free bugs and uninitialized bugs. I am considering Sanitizer(Memory and/or Address) and Valgrind. But I have very little idea about their advantages and disadvantages. Can anyone tell the main features,…
kayas
  • 541
  • 1
  • 4
  • 12
35
votes
3 answers

How can I break on UBSan reports in gdb and continue?

Recent versions of GCC and Clang feature Undefined Behavior Sanitizer (UBSan) which is a compile flag (-fsanitize=undefined) that adds runtime instrumentation code. On errors, a warning such as this one is shown: packet-ber.c:1917:23: runtime…
Lekensteyn
  • 58,351
  • 21
  • 146
  • 179
33
votes
3 answers

Meaningful stack traces for address sanitizer in GCC

I just tried compiling with GCC and the -fsanitize=address flag. When I run my program, the address sanitizer finds a flaw, but the stack trace is not helpful. How can I configure this so that it points to the source code locations I need to look…
clstaudt
  • 17,395
  • 34
  • 132
  • 209
27
votes
3 answers

Clang Address Sanitizer on OS X

I would like to use clang address sanitizer on OSX Mountain Lion, because Valgrind have problems with memory check on this platform. But when I had the -fsanitize=address during the compilation time (like I see on this page :…
Guillaume
  • 7,941
  • 10
  • 44
  • 62
25
votes
3 answers

Why does ASAN_SYMBOLIZER_PATH no longer work with version adorned binaries

On Ubuntu 14.10, the llvm-symbolizer program is installed as /usr/bin/llvm-symbolizer-3.5. Normally, address sanitizer wants to find a binary named llvm-symbolizer in PATH. However, as a workaround, it was possible to explicitly set…
acm
  • 11,033
  • 5
  • 31
  • 60
22
votes
3 answers

How to make AddressSanitizer not stop after one error (and other issues)

I'm running OS X, 10.8.5; I've installed llvm 3.4 via homebrew (clang version 3.4 (tags/RELEASE_34/final) ), and I'm building with -fsanitize=address. I can get asan working with simple demo programs, but when building against our codebase, I have…
Steve Broberg
  • 3,812
  • 3
  • 23
  • 36
21
votes
2 answers

Address sanitizing Boost.Python modules

My project includes a large C++ library and Python bindings (via Boost.Python). The test suite is mostly written on top of the Python bindings, and I would like to run it with sanitizers, starting with ASAN. I'm running macOS (10.13.1 FWIW, but I…
akim
  • 6,950
  • 1
  • 38
  • 51
19
votes
1 answer

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

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…
fencekicker
  • 574
  • 6
  • 16
18
votes
1 answer

MinGW-w64's gcc and Address Sanitizer

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…
Rick C. Hodgin
  • 443
  • 5
  • 8
17
votes
2 answers

Address Sanitizer-like functionality on MSVC

Coming from Linux/gcc/clang I find myself working more and more on Windows/Visual Studio. What I am really missing there is the address sanitizer (bounds checking, leaks, use after free,...). I've done some research and also tried a few things but…
Frank Meerkötter
  • 2,570
  • 2
  • 18
  • 26
17
votes
1 answer

-fsanitize not using gold linker in GCC-6.1

Update (30-Sept-2016) The Ubuntu build of gcc-6.2 ((Ubuntu 6.2.0-3ubuntu11~16.04) 6.2.0 20160901) no longer has this issue. I'm using the Ubuntu build of gcc-6.1[1] ((Ubuntu 6.1.1-3ubuntu11~14.04.1) 6.1.1 20160511), GNU binutils 2.24, and libstdc++…
Tim
  • 1,457
  • 9
  • 14
16
votes
1 answer

std::string_view on temporary string - catch by ASan

This is dangling pointer|reference example: #include #include #include std::string foo() { return "test"; } int main() { std::string_view bar = foo(); // bar is pointed to destructed string std::cout…
vladon
  • 7,412
  • 1
  • 35
  • 75
13
votes
5 answers

How do I get line numbers in the debug output with clang's -fsanitize=address?

I am trying to debug a memory error detected by clang with asan, but missed by valgrind. But I cannot get my clang built binary to give me any useful debugging information. I can demonstrate this with a short test program: #include…
detly
  • 26,649
  • 13
  • 85
  • 142
1
2 3
25 26