Category : address-sanitizer

I have a code similar to below code A.mm – (void)Foo { const unsigned long long dataLen = 0; // In a particular case dataLen is 0 NSMutableData* data = [NSMutableData dataWithLength:dataLen]; b->TestGetData(data.mutableBytes, data.length); } B.cpp void B::TestGetData(void* data, unsigned long long dataLength) { memset(data, 0, (size_t)dataLength); std::string reqBody = ""; // in a particular ..

Read more

I am using Clion and I want to use ASAN address Sanitizer, when I compile the file with ASAN here I get the following errors: c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: cannot find -lasan c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: cannot find -lubsan Here is my CMakeLists.txt content: cmake_minimum_required(VERSION 3.17) project(untitled3) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_FLAGS "-Wall -Werror -Wsign-compare") set(CMAKE_CXX_FLAGS_ASAN "-g -fsanitize=address,undefined -fno-sanitize-recover=all" CACHE STRING "Compiler flags ..

Read more

Does anybody have any idea why address sanitizer is not flagging this very obvious memory leak class A { public: A() = default; }; TEST_F(LibrdfSerializerTests, Test) { A* a = new A; } built with the following added to cmake: set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address") set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address") Source: Windows Que..

Read more

#include <vector> struct Node; std::vector<Node> heap; struct Node { int x, c; explicit Node(int x): x(x), c(0) {} void update() { if(x > 0) { if(c == 0) { c = heap.size(); heap.emplace_back(x / 2); } heap[c].update(); } } }; int main() { heap.emplace_back(100); heap.back().update(); } Consider the above code. When compiled with g++ -fsanitize=address ..

Read more

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 errors That appears to be true not only for ASAN, but UBSAN as well. This turns out to be particularly inconvenient with UBSAN, since the vptr sanitizer can ..

Read more

I have a strange situation – my program runs into segfault after everything is complete (in cleanup process when calling destructors). It runs into segfault only with debug build (no segfault with release build, address sanitizer build, valgrind). My program is very large (cannot show sources here). We have a std::vector like class which based ..

Read more

What are good ways to debug the following problem? I tried to use address sanitizer and set break point. None of them provide helpful debug message to locate the problem. SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stl_vector.h:1043:34 The following code coming from this problem can reproduce the runtime error: https://leetcode.com/problems/maximum-length-of-pair-chain/ #include <bits/stdc++.h> using namespace std; class Solution { ..

Read more