629 questions
105
votes
7
answers
127k
views
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 ...
56
votes
2
answers
44k
views
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 ...
39
votes
4
answers
34k
views
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,...
35
votes
3
answers
11k
views
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 ...
27
votes
3
answers
22k
views
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 (...
26
votes
1
answer
19k
views
LeakSanitizer not working under gdb in Ubuntu 18.04?
I've upgraded my Linux development VM from Ubuntu 16.04 to 18.04 recently, and noticed one thing that has changed. This is on x86-64. With 16.04, I've always had this workflow where I'd build the ...
23
votes
2
answers
2k
views
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 ...
22
votes
4
answers
56k
views
undefined reference to '_asan_init_v4' when compiling
When linking my code compiled with the AddressSanitizer tool, I'm getting many errors of the kind undefined reference to '_asan_init_v4'.
clang -fPIC -g -fno-omit-frame-pointer -DNDEBUG -Wl,-z,defs \
...
21
votes
1
answer
12k
views
Getting new-delete-type-mismatch from ASAN
I compiled my code using -fsanitize=address and am getting this error:
==53702==ERROR: AddressSanitizer: new-delete-type-mismatch on 0x60300000efe0 in thread T0:
object passed to delete has wrong ...
19
votes
2
answers
18k
views
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 ...
18
votes
3
answers
6k
views
Clang 8 with MinGW-w64: How do I use address- & UB sanitizers?
Clang 8 release notes have this promising line:
Allow using Address Sanitizer and Undefined Behaviour Sanitizer on MinGW.
However, I unable to figure out how to use those properly.
I'm using ...
18
votes
1
answer
16k
views
undefined symbol: __asan_option_detect_stack_use_after_return
I'm trying to compile C++ using clang's address sanitizer to output the sanitize results within a core dump, so I added:
CXXFLAGS += -fsanitize=address
to have the compiler options:
/opt/llvm-3.8.0/...
17
votes
1
answer
7k
views
Address Sanitizer on a python extension
I am trying to compile a python extension with Address Sanitizer. When I load the extension, I get
Traceback (most recent call last):
File "test.py", line 2, in <module>
from extension ...
17
votes
1
answer
892
views
std::string_view on temporary string - catch by ASan
This is dangling pointer|reference example:
#include <string>
#include <string_view>
#include <iostream>
std::string foo() {
return "test";
}
int main() {
std::string_view ...
14
votes
1
answer
28k
views
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 ...
14
votes
1
answer
2k
views
using address sanitizer with OpenCV
I'm trying to use Google's Address Sanitizer with a CUDA project, more precisely with OpenCV cuda functions. However I got an 'out of memory' error on the first cuda call.
OpenCV Error: Gpu API call (...
13
votes
2
answers
16k
views
Get line numbers with AddressSanitizer output?
I'm trying to get AddressSanitizer to produce line numbers in its stack traces. I've tried on a Mac and a Fedora 19 system and had similar results.
Here is a simple program:
#include <cstdio>
#...
13
votes
4
answers
4k
views
AddressSanitizer randomly throws SIGSEGV with no explanation [duplicate]
Project
I have a game project in C++ that I'm currently developing.
I compile every source file with -g3 -std=c++2a -Wall ... -fsanitize=address -fsanitize=leak to check for leaks and Segfaults
The ...
12
votes
3
answers
3k
views
Can GCC's ASAN provide the same memory safety as Rust?
Rust is known as a memory-safe language, but there is a security feature in GCC called AddressSanitizer (ASAN):
./configure CFLAGS="-fsanitize=address -g" CXXFLAGS="-fsanitize=address -g" LDFLAGS="-...
12
votes
2
answers
16k
views
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 ...
11
votes
1
answer
914
views
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 ...
11
votes
1
answer
8k
views
Address Sanitizer Warning
For a few days now I get the following issue when starting up the Address Sanitizer within Xcode 7.3. The error messages printed to the Xcode console when the Sanitizer found an issue (that was ...
10
votes
2
answers
5k
views
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 > ...
10
votes
2
answers
10k
views
How to log errors thrown from Google AddressSanitizer to a log file
AddressSanitizer by default throws all errors to shell itself, hence I tried running my ASAN build with following command;
>MCTester_ASAN>asan.log
==15619==ERROR: AddressSanitizer: heap-buffer-...
10
votes
0
answers
7k
views
Cannot use fsanitize=address in minGW compiler
My C++ Setup INFO :
OS - Windows 10,
IDE - VS Code,
compiler - MinGw
ISSUE :
I recently found sanitizers for C++ to catch some runtime errors like out of bound array access with -fsanitize=address and ...