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
5
votes
2 answers

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-overflow on address 0x61400000f9d0 at pc 0x46cff2 bp…
Gayan Pathirage
  • 1,979
  • 1
  • 24
  • 21
5
votes
2 answers

How can I know if Leak Sanitizer is enabled at compile time?

The GCC and Clang compilers both have support for LeakSanitizer which helps finding memory leaks in C programs. Sometimes a memory leak is unavoidable (because it is being tested in a test suite for example). Such memory can be annotated using the…
Lekensteyn
  • 64,486
  • 22
  • 159
  • 192
4
votes
1 answer

Does Qt leak memory?

If I compile this Qt "hello world": #include #include int main( int argc, char **argv ) { QApplication a( argc, argv ); QPushButton hello( "Hello world!" ); hello.resize( 100, 30 ); …
MWB
  • 11,740
  • 6
  • 46
  • 91
4
votes
1 answer

AddressSanitizer: invalid-pointer-pair from libc++ string __addr_in_range

The following simple program makes AddressSanitizer to report "invalid-pointer-pair" with latest master build of Clang (doesn't happen with the latest official release 15): #include #include constexpr std::string_view str =…
notsurewhattodo
  • 446
  • 4
  • 11
4
votes
1 answer

Address sanitizer does not detect out-of-bounds

I'm learning about address sanitizers: #include int main(int argc, char **argv) { int array[30]={0}; (void) printf("%d\n", array[179]); // <--- should crash, right? return 0; } But I can't trigger any error / warning: $…
OrenIshShalom
  • 5,974
  • 9
  • 37
  • 87
4
votes
1 answer

How to add sanitizer support to STM32 ARM GCC?

I am working on a large embedded system (STM32F423 CPU and CubeIDE environment on Windows, all the code is in C), and recently I found out that there must be a buffer overflow somewhere. The mbedtls library reports an error suggesting the server did…
4
votes
2 answers

rust library returned Box object is automatically freed in C -- EDIT: not freed

I have a feeling that ONE rust Box (as struct Context * in C) is automatically freed when leaving main. I have a rust library /home/codes/libspeakdet.so from following code in lib.rs compiled with cargo build pub struct Context { pub sim:…
Catau
  • 55
  • 8
4
votes
1 answer

Using Address Sanitizer or other Undefined Behavior Sanitizers in Production?

In the past there have been concerns about using ASAN in production in certain environments: https://seclists.org/oss-sec/2016/q1/363 . The comment is from 2016 - what is the landscape like today? Is it recommendable to use the sanitizers here in a…
ambiso
  • 559
  • 3
  • 10
4
votes
1 answer

AddressSanitizer: No matching source file lines in the report after separating debuginfo

CentOS Linux release 7.6.1810 (Core) g++ (GCC) 6.5.0 libasan3-6.3.1-3.1.el6.x86_64 I'm using AddressSanitizer to detect memory error. Unlike the common case, I need to build a rpm package rather than compile source code and run it directly. I have…
Matt
  • 41
  • 1
4
votes
1 answer

Asan dynamic runtime is missing on Ubuntu 18+

If I compile a simple program (sample.cpp): #include int main() { printf("Hello, World"); return 0; } with a shared sanitizer library, i.e. clang++-12 -fsanitize=address -shared-libsan sample.cpp -o sample I am getting the following…
Serge Rogatch
  • 13,865
  • 7
  • 86
  • 158
4
votes
0 answers

Why do the clang sanitizers not link the sanitizer runtimes when linking shared libraries

Right in the docs for the address sanitizer (https://releases.llvm.org/7.0.0/tools/clang/docs/AddressSanitizer.html), it states that: When linking shared libraries, the AddressSanitizer run-time is not linked, so -Wl,-z,defs may cause link…
acm
  • 12,183
  • 5
  • 39
  • 68
4
votes
0 answers

How to enable sanitizers for Visual Studio projects via CMake?

I need to set address sanitizers for my Visual Studio project via my CMake file. I can't make use of the GUI option for enabling sanitizers in VS since I need sanitizers to be enabled in my CI/CD flow.
4
votes
1 answer

C++ coroutines: Is it valid to call `handle.destroy` from the final suspend point?

Is it valid to call handle.destroy() from within the final suspension of a C++ coroutine? From my understanding, this should be fine because the coroutine is currently suspended and it won't be resumed again. Still, AddressSanitizer reports a…
Vogelsgesang
  • 684
  • 1
  • 4
  • 15
4
votes
1 answer

VC2019 address sanitizer 64 bit link error on windows "unresolved external symbol __asan_shadow_memory_dynamic_address"

The following simple program #include int main(int argc, char **argv) { char* arr=malloc(10); arr[10]='\0'; return 0; } builds fine with VC2019 16.8.2 in 32 bit dynamic linking cl -Zi -fsanitize=address -MD…
Leo
  • 925
  • 10
  • 24
4
votes
1 answer

Can I apply c++ sanitizer to only my part of the program but not thirdparty libraries

I have a project using thrift/jemalloc, and I want to use C++ sanitizer to look for memory leaks. The project build thrift from source. When I add -fsanitize=address -fno-omit-frame-pointer to the global CXX flag, the compiler complains many errors…
Harper
  • 1,794
  • 14
  • 31