[Bug sanitizer/87840] LSAN misses self-refential shared_ptrs
jengelh at inai dot de
gcc-bugzilla@gcc.gnu.org
Thu Nov 1 13:50:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87840
--- Comment #6 from Jan Engelhardt <jengelh at inai dot de> ---
Found a case where g++-9 also misses a leak when -fsanitize=address is not
present.
14:47 a4:~ > cat y.cpp
#include <memory>
struct S {
std::shared_ptr<S> other;
};
int main()
{
auto e = std::make_shared<S>();
auto f = std::make_shared<S>();
e->other = f;
f->other = e;
}
14:48 a4:~ > g++-9 -ggdb3 -fsanitize=leak y.cpp; ./a.out
14:48 a4:~ > g++-9 -ggdb3 -fsanitize=address -fsanitize=leak y.cpp; ./a.out
=================================================================
==18624==ERROR: LeakSanitizer: detected memory leaks
[...]
Indirect leak of 32 byte(s) in 1 object(s) allocated from:
Indirect leak of 32 byte(s) in 1 object(s) allocated from:
SUMMARY: AddressSanitizer: 64 byte(s) leaked in 2 allocation(s).
More information about the Gcc-bugs
mailing list