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 from thrift and stop further compilation. (One example below). I cannot see any error from my own code.
Indirect leak of 168 byte(s) in 1 object(s) allocated from:
#0 0x7f62c7e8bc3b in operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xfc3b)
#1 0x56164a1712be in yyparse() /tmp/tmp.BnUAMaceSS/cmake-build-debug-parallel-chameleon/thrift_ep-prefix/src/thrift_ep/compiler/cpp/src/thrift/thrifty.yy:589
#2 0x561649e7ba1e in parse(t_program*, t_program*) /tmp/tmp.BnUAMaceSS/cmake-build-debug-parallel-chameleon/thrift_ep-prefix/src/thrift_ep/compiler/cpp/src/thrift/main.cc:973
#3 0x561649e7d0a9 in main /tmp/tmp.BnUAMaceSS/cmake-build-debug-parallel-chameleon/thrift_ep-prefix/src/thrift_ep/compiler/cpp/src/thrift/main.cc:1280
#4 0x7f62c750bb96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
As I am only interested in the memory leak in my own project, I try to remove -fsanitize=address
from the global CXX flag and add it only when compiling my own sources. But now I get many link errors complaining that it cannot find the function asan_report
.
/usr/include/c++/7/bits/std_function.h:183: undefined reference to `__asan_report_store8'
/usr/include/c++/7/bits/std_function.h:183: undefined reference to `__asan_report_load8'
../../../debug/liblqf.a(filter.cc.o): In function `std::_Function_base::_Base_manager<lqf::sboost::DictLess<parquet::PhysicalType<(parquet::Type::type)1> >::scanPage(unsigned long, unsigned char const*, unsigned long*, unsigned long)::{lambda(int)#1}>::_M_init_functor(std::_Any_data&, {lambda(int)#1}&&, std::integral_constant<bool, true>)':
Is there a way I can see only sanitizer results from my own code?