Most of the listed locations are creating boost::shared_ptr objects. Does address sanitizer work well with Boost library?
I tried a few share_ptr tests with sanitize address checking and it
seems okay:
for i in tstaddrsan4 tstaddrsan5 tstaddrsan6 ; do echo '##### ' $i.c ;
g++ -fsanitize=address -fsanitize=leak -g -fpermissive $i.c -o $i.x &&
./$i.x ; done
##### tstaddrsan4.c
abcdefghijklmnopqrstuvwxyz
##### tstaddrsan5.c
abcdefghijklmnopqrstuvwxyz
=================================================================
==4448==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 1024 byte(s) in 1 object(s) allocated from:
#0 0x7f52e655fbd7 in operator new[](unsigned long)
(/lib64/libasan.so.5+0x10fbd7)
#1 0x4011fe in main
/work/scox/dyn/smoke-test/dynamic-static/tstaddrsan5.c:10
#2 0x7f52e5f53f42 in __libc_start_main (/lib64/libc.so.6+0x23f42)
SUMMARY: AddressSanitizer: 1024 byte(s) leaked in 1 allocation(s).
##### tstaddrsan6.c
hello, world!
// g++ -fsanitize=address -fsanitize=leak
#include <iostream>
#include <memory>
#include <cstring>
using namespace std;
int main(int argc, char** argv)
{
struct buffer_class {
string data;
buffer_class(char *data_) {data = data_;}
};
auto buffer = make_shared<buffer_class> ("abcdefghijklmnopqrstuvwxyz");
std::cout << buffer->data << '\n';
}
#include <iostream>
#include <memory>
#include <cstring>
using namespace std;
int main(int argc, char** argv)
{
typedef char buf[1024];
char *buffer = new (buf);
strcpy (buffer,"abcdefghijklmnopqrstuvwxyz");
std::cout << buffer << '\n';
}
// g++ -fsanitize=address -fsanitize=leak
#include <iostream>
#include <cstring>
#include <boost/shared_ptr.hpp>
#include <boost/make_shared.hpp>
using namespace std;
using namespace boost;
int main(int argc, char** argv)
{
string str = "hello, world!";
boost::shared_ptr<std::string> anint = boost::make_shared<std::string>("hello, world!");
std::cout << *anint << '\n';
}
|