Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: memory leak on ApproxHashSset #4

Open
HiroIshida opened this issue Nov 4, 2022 · 1 comment
Open

bug: memory leak on ApproxHashSset #4

HiroIshida opened this issue Nov 4, 2022 · 1 comment

Comments

@HiroIshida
Copy link
Owner

HiroIshida commented Nov 4, 2022

Note

As for leak realted enum, the problem is already reported in
pybind/pybind11#3865

So, probably ApproxHashSset is the only thing we have to fix

reproduce

at v0.0.2 reproduce

export LD_PRELOAD=/lib/x86_64-linux-gnu/libasan.so.5
python3 incremetal_update.py 2> log.txt

output
log.txt

at v0.0.1, the shorted error message is outputted

h-ishida@stone-jsk:~/cpp/voxbloxpy/example$ python3 incremetal_update.py 

h-ishida@stone-jsk:~/cpp/voxbloxpy/example$ python3 incremetal_update.py 

=================================================================
==168826==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 8468608 byte(s) in 1 object(s) allocated from:
    #0 0x7f9239b81587 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cc:104
    #1 0x7f91c6176794 in __gnu_cxx::new_allocator<std::atomic<unsigned long> >::allocate(unsigned long, void const*) /usr/include/c++/9/ext/new_allocator.h:114
    #2 0x7f91c616c353 in std::allocator_traits<std::allocator<std::atomic<unsigned long> > >::allocate(std::allocator<std::atomic<unsigned long> >&, unsigned long) /usr/include/c++/9/bits/alloc_traits.h:443
    #3 0x7f91c615d4c9 in std::_Vector_base<std::atomic<unsigned long>, std::allocator<std::atomic<unsigned long> > >::_M_allocate(unsigned long) /usr/include/c++/9/bits/stl_vector.h:343
    #4 0x7f91c6149938 in std::_Vector_base<std::atomic<unsigned long>, std::allocator<std::atomic<unsigned long> > >::_M_create_storage(unsigned long) /usr/include/c++/9/bits/stl_vector.h:358
    #5 0x7f91c612c52a in std::_Vector_base<std::atomic<unsigned long>, std::allocator<std::atomic<unsigned long> > >::_Vector_base(unsigned long, std::allocator<std::atomic<unsigned long> > const&) /usr/include/c++/9/bits/stl_vector.h:302
    #6 0x7f91c61123d0 in std::vector<std::atomic<unsigned long>, std::allocator<std::atomic<unsigned long> > >::vector(unsigned long, std::allocator<std::atomic<unsigned long> > const&) /usr/include/c++/9/bits/stl_vector.h:508
    #7 0x7f91c60f817c in voxblox::ApproxHashSet<20ul, 10000ul, Eigen::Matrix<long, 3, 1, 0, 3, 1>, voxblox::LongIndexHash>::ApproxHashSet() (/home/h-ishida/cpp/voxbloxpy/python/voxbloxpy/_voxbloxpy.cpython-38-x86_64-linux-gnu.so+0x3a017c)
    #8 0x7f91c60e0e74 in voxblox::FastTsdfIntegrator::FastTsdfIntegrator(voxblox::TsdfIntegratorBase::Config const&, voxblox::Layer<voxblox::TsdfVoxel>*) (/home/h-ishida/cpp/voxbloxpy/python/voxbloxpy/_voxbloxpy.cpython-38-x86_64-linux-gnu.so+0x388e74)
    #9 0x7f91c60e4a16 in PyTsdfMap::PyTsdfMap(voxblox::Layer<voxblox::TsdfVoxel> const&) (/home/h-ishida/cpp/voxbloxpy/python/voxbloxpy/_voxbloxpy.cpython-38-x86_64-linux-gnu.so+0x38ca16)
    #10 0x7f91c60e40f7 in PyTsdfMap::PyTsdfMap(float, int) (/home/h-ishida/cpp/voxbloxpy/python/voxbloxpy/_voxbloxpy.cpython-38-x86_64-linux-gnu.so+0x38c0f7)
    #11 0x7f91c60e5e95 in PyEsdfMap::PyEsdfMap(voxblox::Layer<voxblox::EsdfVoxel> const&, float, float) (/home/h-ishida/cpp/voxbloxpy/python/voxbloxpy/_voxbloxpy.cpython-38-x86_64-linux-gnu.so+0x38de95)
    #12 0x7f91c60e5ba2 in PyEsdfMap::PyEsdfMap(float, int, float, float) (/home/h-ishida/cpp/voxbloxpy/python/voxbloxpy/_voxbloxpy.cpython-38-x86_64-linux-gnu.so+0x38dba2)
    #13 0x7f91c61374d8 in PyEsdfMap* pybind11::detail::initimpl::construct_or_initialize<PyEsdfMap, float, int, float, float, 0>(float&&, int&&, float&&, float&&) (/home/h-ishida/cpp/voxbloxpy/python/voxbloxpy/_voxbloxpy.cpython-38-x86_64-linux-gnu.so+0x3df4d8)
    #14 0x7f91c611bfa1 in pybind11::detail::initimpl::constructor<float, int, float, float>::execute<pybind11::class_<PyEsdfMap>, , 0>(pybind11::class_<PyEsdfMap>&)::{lambda(pybind11::detail::value_and_holder&, float, int, float, float)#1}::operator()(pybind11::detail::value_and_holder&, float, int, float, float) const (/home/h-ishida/cpp/voxbloxpy/python/voxbloxpy/_voxbloxpy.cpython-38-x86_64-linux-gnu.so+0x3c3fa1)
    #15 0x7f91c617a356 in void pybind11::detail::argument_loader<pybind11::detail::value_and_holder&, float, int, float, float>::call_impl<void, pybind11::detail::initimpl::constructor<float, int, float, float>::execute<pybind11::class_<PyEsdfMap>, , 0>(pybind11::class_<PyEsdfMap>&)::{lambda(pybind11::detail::value_and_holder&, float, int, float, float)#1}&, 0ul, 1ul, 2ul, 3ul, 4ul, pybind11::detail::void_type>(pybind11::detail::initimpl::constructor<float, int, float, float>::execute<pybind11::class_<PyEsdfMap>, , 0>(pybind11::class_<PyEsdfMap>&)::{lambda(pybind11::detail::value_and_holder&, float, int, float, float)#1}&, std::integer_sequence<unsigned long, 0ul, 1ul, 2ul, 3ul, 4ul>, pybind11::detail::void_type&&) && (/home/h-ishida/cpp/voxbloxpy/python/voxbloxpy/_voxbloxpy.cpython-38-x86_64-linux-gnu.so+0x422356)
    #16 0x7f91c6171b67 in std::enable_if<std::is_void<void>::value, pybind11::detail::void_type>::type pybind11::detail::argument_loader<pybind11::detail::value_and_holder&, float, int, float, float>::call<void, pybind11::detail::void_type, pybind11::detail::initimpl::constructor<float, int, float, float>::execute<pybind11::class_<PyEsdfMap>, , 0>(pybind11::class_<PyEsdfMap>&)::{lambda(pybind11::detail::value_and_holder&, float, int, float, float)#1}&>(pybind11::detail::initimpl::constructor<float, int, float, float>::execute<pybind11::class_<PyEsdfMap>, , 0>(pybind11::class_<PyEsdfMap>&)::{lambda(pybind11::detail::value_and_holder&, float, int, float, float)#1}&) && (/home/h-ishida/cpp/voxbloxpy/python/voxbloxpy/_voxbloxpy.cpython-38-x86_64-linux-gnu.so+0x419b67)
    #17 0x7f91c6162938 in pybind11::cpp_function::initialize<pybind11::detail::initimpl::constructor<float, int, float, float>::execute<pybind11::class_<PyEsdfMap>, , 0>(pybind11::class_<PyEsdfMap>&)::{lambda(pybind11::detail::value_and_holder&, float, int, float, float)#1}, void, pybind11::detail::value_and_holder&, float, int, float, float, pybind11::name, pybind11::is_method, pybind11::sibling, pybind11::detail::is_new_style_constructor>(pybind11::class_<PyEsdfMap>&&, void (*)(pybind11::detail::value_and_holder&, float, int, float, float), pybind11::name const&, pybind11::is_method const&, pybind11::sibling const&, pybind11::detail::is_new_style_constructor const&)::{lambda(pybind11::detail::function_call&)#3}::operator()(pybind11::detail::function_call) const (/home/h-ishida/cpp/voxbloxpy/python/voxbloxpy/_voxbloxpy.cpython-38-x86_64-linux-gnu.so+0x40a938)
    #18 0x7f91c6162aae in pybind11::cpp_function::initialize<pybind11::detail::initimpl::constructor<float, int, float, float>::execute<pybind11::class_<PyEsdfMap>, , 0>(pybind11::class_<PyEsdfMap>&)::{lambda(pybind11::detail::value_and_holder&, float, int, float, float)#1}, void, pybind11::detail::value_and_holder&, float, int, float, float, pybind11::name, pybind11::is_method, pybind11::sibling, pybind11::detail::is_new_style_constructor>(pybind11::class_<PyEsdfMap>&&, void (*)(pybind11::detail::value_and_holder&, float, int, float, float), pybind11::name const&, pybind11::is_method const&, pybind11::sibling const&, pybind11::detail::is_new_style_constructor const&)::{lambda(pybind11::detail::function_call&)#3}::_FUN(pybind11::detail::function_call) (/home/h-ishida/cpp/voxbloxpy/python/voxbloxpy/_voxbloxpy.cpython-38-x86_64-linux-gnu.so+0x40aaae)
    #19 0x7f91c60d7b37 in pybind11::cpp_function::dispatcher(_object*, _object*, _object*) (/home/h-ishida/cpp/voxbloxpy/python/voxbloxpy/_voxbloxpy.cpython-38-x86_64-linux-gnu.so+0x37fb37)
    #20 0x5f3988 in PyCFunction_Call (/usr/bin/python3.8+0x5f3988)

Direct leak of 8468608 byte(s) in 1 object(s) allocated from:
    #0 0x7f9239b81587 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cc:104
    #1 0x7f91c6176794 in __gnu_cxx::new_allocator<std::atomic<unsigned long> >::allocate(unsigned long, void const*) /usr/include/c++/9/ext/new_allocator.h:114
    #2 0x7f91c616c353 in std::allocator_traits<std::allocator<std::atomic<unsigned long> > >::allocate(std::allocator<std::atomic<unsigned long> >&, unsigned long) /usr/include/c++/9/bits/alloc_traits.h:443
    #3 0x7f91c615d4c9 in std::_Vector_base<std::atomic<unsigned long>, std::allocator<std::atomic<unsigned long> > >::_M_allocate(unsigned long) /usr/include/c++/9/bits/stl_vector.h:343
    #4 0x7f91c6149938 in std::_Vector_base<std::atomic<unsigned long>, std::allocator<std::atomic<unsigned long> > >::_M_create_storage(unsigned long) /usr/include/c++/9/bits/stl_vector.h:358
    #5 0x7f91c612c52a in std::_Vector_base<std::atomic<unsigned long>, std::allocator<std::atomic<unsigned long> > >::_Vector_base(unsigned long, std::allocator<std::atomic<unsigned long> > const&) /usr/include/c++/9/bits/stl_vector.h:302
    #6 0x7f91c61123d0 in std::vector<std::atomic<unsigned long>, std::allocator<std::atomic<unsigned long> > >::vector(unsigned long, std::allocator<std::atomic<unsigned long> > const&) /usr/include/c++/9/bits/stl_vector.h:508
    #7 0x7f91c60f817c in voxblox::ApproxHashSet<20ul, 10000ul, Eigen::Matrix<long, 3, 1, 0, 3, 1>, voxblox::LongIndexHash>::ApproxHashSet() (/home/h-ishida/cpp/voxbloxpy/python/voxbloxpy/_voxbloxpy.cpython-38-x86_64-linux-gnu.so+0x3a017c)
    #8 0x7f91c60e0e62 in voxblox::FastTsdfIntegrator::FastTsdfIntegrator(voxblox::TsdfIntegratorBase::Config const&, voxblox::Layer<voxblox::TsdfVoxel>*) (/home/h-ishida/cpp/voxbloxpy/python/voxbloxpy/_voxbloxpy.cpython-38-x86_64-linux-gnu.so+0x388e62)
    #9 0x7f91c60e4a16 in PyTsdfMap::PyTsdfMap(voxblox::Layer<voxblox::TsdfVoxel> const&) (/home/h-ishida/cpp/voxbloxpy/python/voxbloxpy/_voxbloxpy.cpython-38-x86_64-linux-gnu.so+0x38ca16)
    #10 0x7f91c60e40f7 in PyTsdfMap::PyTsdfMap(float, int) (/home/h-ishida/cpp/voxbloxpy/python/voxbloxpy/_voxbloxpy.cpython-38-x86_64-linux-gnu.so+0x38c0f7)
    #11 0x7f91c60e5e95 in PyEsdfMap::PyEsdfMap(voxblox::Layer<voxblox::EsdfVoxel> const&, float, float) (/home/h-ishida/cpp/voxbloxpy/python/voxbloxpy/_voxbloxpy.cpython-38-x86_64-linux-gnu.so+0x38de95)
    #12 0x7f91c60e5ba2 in PyEsdfMap::PyEsdfMap(float, int, float, float) (/home/h-ishida/cpp/voxbloxpy/python/voxbloxpy/_voxbloxpy.cpython-38-x86_64-linux-gnu.so+0x38dba2)
    #13 0x7f91c61374d8 in PyEsdfMap* pybind11::detail::initimpl::construct_or_initialize<PyEsdfMap, float, int, float, float, 0>(float&&, int&&, float&&, float&&) (/home/h-ishida/cpp/voxbloxpy/python/voxbloxpy/_voxbloxpy.cpython-38-x86_64-linux-gnu.so+0x3df4d8)
    #14 0x7f91c611bfa1 in pybind11::detail::initimpl::constructor<float, int, float, float>::execute<pybind11::class_<PyEsdfMap>, , 0>(pybind11::class_<PyEsdfMap>&)::{lambda(pybind11::detail::value_and_holder&, float, int, float, float)#1}::operator()(pybind11::detail::value_and_holder&, float, int, float, float) const (/home/h-ishida/cpp/voxbloxpy/python/voxbloxpy/_voxbloxpy.cpython-38-x86_64-linux-gnu.so+0x3c3fa1)
    #15 0x7f91c617a356 in void pybind11::detail::argument_loader<pybind11::detail::value_and_holder&, float, int, float, float>::call_impl<void, pybind11::detail::initimpl::constructor<float, int, float, float>::execute<pybind11::class_<PyEsdfMap>, , 0>(pybind11::class_<PyEsdfMap>&)::{lambda(pybind11::detail::value_and_holder&, float, int, float, float)#1}&, 0ul, 1ul, 2ul, 3ul, 4ul, pybind11::detail::void_type>(pybind11::detail::initimpl::constructor<float, int, float, float>::execute<pybind11::class_<PyEsdfMap>, , 0>(pybind11::class_<PyEsdfMap>&)::{lambda(pybind11::detail::value_and_holder&, float, int, float, float)#1}&, std::integer_sequence<unsigned long, 0ul, 1ul, 2ul, 3ul, 4ul>, pybind11::detail::void_type&&) && (/home/h-ishida/cpp/voxbloxpy/python/voxbloxpy/_voxbloxpy.cpython-38-x86_64-linux-gnu.so+0x422356)
    #16 0x7f91c6171b67 in std::enable_if<std::is_void<void>::value, pybind11::detail::void_type>::type pybind11::detail::argument_loader<pybind11::detail::value_and_holder&, float, int, float, float>::call<void, pybind11::detail::void_type, pybind11::detail::initimpl::constructor<float, int, float, float>::execute<pybind11::class_<PyEsdfMap>, , 0>(pybind11::class_<PyEsdfMap>&)::{lambda(pybind11::detail::value_and_holder&, float, int, float, float)#1}&>(pybind11::detail::initimpl::constructor<float, int, float, float>::execute<pybind11::class_<PyEsdfMap>, , 0>(pybind11::class_<PyEsdfMap>&)::{lambda(pybind11::detail::value_and_holder&, float, int, float, float)#1}&) && (/home/h-ishida/cpp/voxbloxpy/python/voxbloxpy/_voxbloxpy.cpython-38-x86_64-linux-gnu.so+0x419b67)
    #17 0x7f91c6162938 in pybind11::cpp_function::initialize<pybind11::detail::initimpl::constructor<float, int, float, float>::execute<pybind11::class_<PyEsdfMap>, , 0>(pybind11::class_<PyEsdfMap>&)::{lambda(pybind11::detail::value_and_holder&, float, int, float, float)#1}, void, pybind11::detail::value_and_holder&, float, int, float, float, pybind11::name, pybind11::is_method, pybind11::sibling, pybind11::detail::is_new_style_constructor>(pybind11::class_<PyEsdfMap>&&, void (*)(pybind11::detail::value_and_holder&, float, int, float, float), pybind11::name const&, pybind11::is_method const&, pybind11::sibling const&, pybind11::detail::is_new_style_constructor const&)::{lambda(pybind11::detail::function_call&)#3}::operator()(pybind11::detail::function_call) const (/home/h-ishida/cpp/voxbloxpy/python/voxbloxpy/_voxbloxpy.cpython-38-x86_64-linux-gnu.so+0x40a938)
    #18 0x7f91c6162aae in pybind11::cpp_function::initialize<pybind11::detail::initimpl::constructor<float, int, float, float>::execute<pybind11::class_<PyEsdfMap>, , 0>(pybind11::class_<PyEsdfMap>&)::{lambda(pybind11::detail::value_and_holder&, float, int, float, float)#1}, void, pybind11::detail::value_and_holder&, float, int, float, float, pybind11::name, pybind11::is_method, pybind11::sibling, pybind11::detail::is_new_style_constructor>(pybind11::class_<PyEsdfMap>&&, void (*)(pybind11::detail::value_and_holder&, float, int, float, float), pybind11::name const&, pybind11::is_method const&, pybind11::sibling const&, pybind11::detail::is_new_style_constructor const&)::{lambda(pybind11::detail::function_call&)#3}::_FUN(pybind11::detail::function_call) (/home/h-ishida/cpp/voxbloxpy/python/voxbloxpy/_voxbloxpy.cpython-38-x86_64-linux-gnu.so+0x40aaae)
    #19 0x7f91c60d7b37 in pybind11::cpp_function::dispatcher(_object*, _object*, _object*) (/home/h-ishida/cpp/voxbloxpy/python/voxbloxpy/_voxbloxpy.cpython-38-x86_64-linux-gnu.so+0x37fb37)
    #20 0x5f3988 in PyCFunction_Call (/usr/bin/python3.8+0x5f3988)

Direct leak of 1005464 byte(s) in 320 object(s) allocated from:
    #0 0x7f9239b7f808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x5ba023 in PyObject_Malloc (/usr/bin/python3.8+0x5ba023)

Direct leak of 80523 byte(s) in 63 object(s) allocated from:
    #0 0x7f9239b7f808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x589ef6  (/usr/bin/python3.8+0x589ef6)

Direct leak of 23960 byte(s) in 17 object(s) allocated from:
    #0 0x7f9239b7f808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x4f08d9  (/usr/bin/python3.8+0x4f08d9)

Direct leak of 19944 byte(s) in 22 object(s) allocated from:
    #0 0x7f9239b7f808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x5d42e7 in PyDict_Copy (/usr/bin/python3.8+0x5d42e7)

Direct leak of 7559 byte(s) in 44 object(s) allocated from:
    #0 0x7f9239b7f808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x5b9597  (/usr/bin/python3.8+0x5b9597)

Direct leak of 4376 byte(s) in 7 object(s) allocated from:
    #0 0x7f9239b7f808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x53c017 in _PyObject_GC_NewVar (/usr/bin/python3.8+0x53c017)

Direct leak of 4040 byte(s) in 6 object(s) allocated from:
    #0 0x7f9239b7f808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x5f8a00 in PyBytes_FromStringAndSize (/usr/bin/python3.8+0x5f8a00)

Direct leak of 3397 byte(s) in 1 object(s) allocated from:
    #0 0x7f9239b7fc3e in __interceptor_realloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:163
    #1 0x59009c  (/usr/bin/python3.8+0x59009c)

Direct leak of 2808 byte(s) in 3 object(s) allocated from:
    #0 0x7f9239b7f808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x5a9cc6 in PyType_GenericAlloc (/usr/bin/python3.8+0x5a9cc6)

Direct leak of 672 byte(s) in 1 object(s) allocated from:
    #0 0x7f9239b7fc3e in __interceptor_realloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:163
    #1 0x53be71 in _PyObject_GC_Resize (/usr/bin/python3.8+0x53be71)

Direct leak of 412 byte(s) in 38 object(s) allocated from:
    #0 0x7f9239b7f808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x7f92351128f9 in PyUFunc_FromFuncAndDataAndSignatureAndIdentity (/home/h-ishida/.local/lib/python3.8/site-packages/numpy/core/_multiarray_umath.cpython-38-x86_64-linux-gnu.so+0x35b8f9)

Direct leak of 64 byte(s) in 2 object(s) allocated from:
    #0 0x7f9239b7f808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x53dca0 in PyThread_allocate_lock (/usr/bin/python3.8+0x53dca0)

Direct leak of 24 byte(s) in 1 object(s) allocated from:
    #0 0x7f9239b7fc3e in __interceptor_realloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:163
    #1 0x7f9235112de0 in PyUFunc_FromFuncAndDataAndSignatureAndIdentity (/home/h-ishida/.local/lib/python3.8/site-packages/numpy/core/_multiarray_umath.cpython-38-x86_64-linux-gnu.so+0x35bde0)

Direct leak of 24 byte(s) in 1 object(s) allocated from:
    #0 0x7f9239b7fc3e in __interceptor_realloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:163
    #1 0x7f9235112df8 in PyUFunc_FromFuncAndDataAndSignatureAndIdentity (/home/h-ishida/.local/lib/python3.8/site-packages/numpy/core/_multiarray_umath.cpython-38-x86_64-linux-gnu.so+0x35bdf8)

Direct leak of 23 byte(s) in 1 object(s) allocated from:
    #0 0x7f9239b7f808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x7f9235112938 in PyUFunc_FromFuncAndDataAndSignatureAndIdentity (/home/h-ishida/.local/lib/python3.8/site-packages/numpy/core/_multiarray_umath.cpython-38-x86_64-linux-gnu.so+0x35b938)

Direct leak of 12 byte(s) in 1 object(s) allocated from:
    #0 0x7f9239b7fc3e in __interceptor_realloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:163
    #1 0x7f9235112e13 in PyUFunc_FromFuncAndDataAndSignatureAndIdentity (/home/h-ishida/.local/lib/python3.8/site-packages/numpy/core/_multiarray_umath.cpython-38-x86_64-linux-gnu.so+0x35be13)

Direct leak of 12 byte(s) in 1 object(s) allocated from:
    #0 0x7f9239b7f808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x7f923511299e in PyUFunc_FromFuncAndDataAndSignatureAndIdentity (/home/h-ishida/.local/lib/python3.8/site-packages/numpy/core/_multiarray_umath.cpython-38-x86_64-linux-gnu.so+0x35b99e)

Direct leak of 12 byte(s) in 1 object(s) allocated from:
    #0 0x7f9239b7f808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x7f923511298d in PyUFunc_FromFuncAndDataAndSignatureAndIdentity (/home/h-ishida/.local/lib/python3.8/site-packages/numpy/core/_multiarray_umath.cpython-38-x86_64-linux-gnu.so+0x35b98d)

Indirect leak of 86832 byte(s) in 91 object(s) allocated from:
    #0 0x7f9239b7f808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x5a9cc6 in PyType_GenericAlloc (/usr/bin/python3.8+0x5a9cc6)

Indirect leak of 25279 byte(s) in 13 object(s) allocated from:
    #0 0x7f9239b7f808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x4f08d9  (/usr/bin/python3.8+0x4f08d9)

Indirect leak of 14649 byte(s) in 11 object(s) allocated from:
    #0 0x7f9239b7f808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x5ba023 in PyObject_Malloc (/usr/bin/python3.8+0x5ba023)

Indirect leak of 14458 byte(s) in 12 object(s) allocated from:
    #0 0x7f9239b7f808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x589ef6  (/usr/bin/python3.8+0x589ef6)

Indirect leak of 1344 byte(s) in 2 object(s) allocated from:
    #0 0x7f9239b7f808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x53c017 in _PyObject_GC_NewVar (/usr/bin/python3.8+0x53c017)

Indirect leak of 840 byte(s) in 1 object(s) allocated from:
    #0 0x7f9239b7fc3e in __interceptor_realloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:163
    #1 0x53be71 in _PyObject_GC_Resize (/usr/bin/python3.8+0x53be71)

SUMMARY: AddressSanitizer: 18233944 byte(s) leaked in 662 allocation(s).
@HiroIshida
Copy link
Owner Author

HiroIshida commented Nov 5, 2022

The branch https://github.com/HiroIshida/voxbloxpy/tree/fix_memory_leak provides the minimal example to reproduce the bug.
The following code reproduces the error. Note that this is only happens when using fast integrator. And not occurred when using merged.

from _voxbloxpy import TsdfMap, hoge   
hoge()
h-ishida@stone-jsk:~/cpp/voxbloxpy/build$ python3 tmp.py 

=================================================================
==189192==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 8468608 byte(s) in 1 object(s) allocated from:
    #0 0x7f1b4f190587 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cc:104
    #1 0x7f1b4a78fb10 in __gnu_cxx::new_allocator<std::atomic<unsigned long> >::allocate(unsigned long, void const*) /usr/include/c++/9/ext/new_allocator.h:114
    #2 0x7f1b4a7856cf in std::allocator_traits<std::allocator<std::atomic<unsigned long> > >::allocate(std::allocator<std::atomic<unsigned long> >&, unsigned long) /usr/include/c++/9/bits/alloc_traits.h:443
    #3 0x7f1b4a7767d3 in std::_Vector_base<std::atomic<unsigned long>, std::allocator<std::atomic<unsigned long> > >::_M_allocate(unsigned long) /usr/include/c++/9/bits/stl_vector.h:343
    #4 0x7f1b4a7629f6 in std::_Vector_base<std::atomic<unsigned long>, std::allocator<std::atomic<unsigned long> > >::_M_create_storage(unsigned long) /usr/include/c++/9/bits/stl_vector.h:358
    #5 0x7f1b4a744eda in std::_Vector_base<std::atomic<unsigned long>, std::allocator<std::atomic<unsigned long> > >::_Vector_base(unsigned long, std::allocator<std::atomic<unsigned long> > const&) /usr/include/c++/9/bits/stl_vector.h:302
    #6 0x7f1b4a72ac22 in std::vector<std::atomic<unsigned long>, std::allocator<std::atomic<unsigned long> > >::vector(unsigned long, std::allocator<std::atomic<unsigned long> > const&) /usr/include/c++/9/bits/stl_vector.h:508
    #7 0x7f1b4a7105f2 in voxblox::ApproxHashSet<20ul, 10000ul, Eigen::Matrix<long, 3, 1, 0, 3, 1>, voxblox::LongIndexHash>::ApproxHashSet() (/home/h-ishida/cpp/voxbloxpy/build/_voxbloxpy.cpython-38-x86_64-linux-gnu.so+0x3a05f2)
    #8 0x7f1b4a6f91c2 in voxblox::FastTsdfIntegrator::FastTsdfIntegrator(voxblox::TsdfIntegratorBase::Config const&, voxblox::Layer<voxblox::TsdfVoxel>*) (/home/h-ishida/cpp/voxbloxpy/build/_voxbloxpy.cpython-38-x86_64-linux-gnu.so+0x3891c2)
    #9 0x7f1b4a6c027b in func() /home/h-ishida/cpp/voxbloxpy/wrapper.cpp:30
    #10 0x7f1b4a77a004 in void pybind11::detail::argument_loader<>::call_impl<void, void (*&)(), , pybind11::detail::void_type>(void (*&)(), std::integer_sequence<unsigned long>, pybind11::detail::void_type&&) && (/home/h-ishida/cpp/voxbloxpy/build/_voxbloxpy.cpython-38-x86_64-linux-gnu.so+0x40a004)
    #11 0x7f1b4a766895 in std::enable_if<std::is_void<void>::value, pybind11::detail::void_type>::type pybind11::detail::argument_loader<>::call<void, pybind11::detail::void_type, void (*&)()>(void (*&)()) && (/home/h-ishida/cpp/voxbloxpy/build/_voxbloxpy.cpython-38-x86_64-linux-gnu.so+0x3f6895)
    #12 0x7f1b4a74d637 in pybind11::cpp_function::initialize<void (*&)(), void, , pybind11::name, pybind11::scope, pybind11::sibling>(void (*&)(), void (*)(), pybind11::name const&, pybind11::scope const&, pybind11::sibling const&)::{lambda(pybind11::detail::function_call&)#3}::operator()(pybind11::detail::function_call&) const (/home/h-ishida/cpp/voxbloxpy/build/_voxbloxpy.cpython-38-x86_64-linux-gnu.so+0x3dd637)
    #13 0x7f1b4a74d786 in pybind11::cpp_function::initialize<void (*&)(), void, , pybind11::name, pybind11::scope, pybind11::sibling>(void (*&)(), void (*)(), pybind11::name const&, pybind11::scope const&, pybind11::sibling const&)::{lambda(pybind11::detail::function_call&)#3}::_FUN(pybind11::detail::function_call&) (/home/h-ishida/cpp/voxbloxpy/build/_voxbloxpy.cpython-38-x86_64-linux-gnu.so+0x3dd786)
    #14 0x7f1b4a6efe85 in pybind11::cpp_function::dispatcher(_object*, _object*, _object*) (/home/h-ishida/cpp/voxbloxpy/build/_voxbloxpy.cpython-38-x86_64-linux-gnu.so+0x37fe85)
    #15 0x5f3988 in PyCFunction_Call (/usr/bin/python3.8+0x5f3988)

Direct leak of 8468608 byte(s) in 1 object(s) allocated from:
    #0 0x7f1b4f190587 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cc:104
    #1 0x7f1b4a78fb10 in __gnu_cxx::new_allocator<std::atomic<unsigned long> >::allocate(unsigned long, void const*) /usr/include/c++/9/ext/new_allocator.h:114
    #2 0x7f1b4a7856cf in std::allocator_traits<std::allocator<std::atomic<unsigned long> > >::allocate(std::allocator<std::atomic<unsigned long> >&, unsigned long) /usr/include/c++/9/bits/alloc_traits.h:443
    #3 0x7f1b4a7767d3 in std::_Vector_base<std::atomic<unsigned long>, std::allocator<std::atomic<unsigned long> > >::_M_allocate(unsigned long) /usr/include/c++/9/bits/stl_vector.h:343
    #4 0x7f1b4a7629f6 in std::_Vector_base<std::atomic<unsigned long>, std::allocator<std::atomic<unsigned long> > >::_M_create_storage(unsigned long) /usr/include/c++/9/bits/stl_vector.h:358
    #5 0x7f1b4a744eda in std::_Vector_base<std::atomic<unsigned long>, std::allocator<std::atomic<unsigned long> > >::_Vector_base(unsigned long, std::allocator<std::atomic<unsigned long> > const&) /usr/include/c++/9/bits/stl_vector.h:302
    #6 0x7f1b4a72ac22 in std::vector<std::atomic<unsigned long>, std::allocator<std::atomic<unsigned long> > >::vector(unsigned long, std::allocator<std::atomic<unsigned long> > const&) /usr/include/c++/9/bits/stl_vector.h:508
    #7 0x7f1b4a7105f2 in voxblox::ApproxHashSet<20ul, 10000ul, Eigen::Matrix<long, 3, 1, 0, 3, 1>, voxblox::LongIndexHash>::ApproxHashSet() (/home/h-ishida/cpp/voxbloxpy/build/_voxbloxpy.cpython-38-x86_64-linux-gnu.so+0x3a05f2)
    #8 0x7f1b4a6f91b0 in voxblox::FastTsdfIntegrator::FastTsdfIntegrator(voxblox::TsdfIntegratorBase::Config const&, voxblox::Layer<voxblox::TsdfVoxel>*) (/home/h-ishida/cpp/voxbloxpy/build/_voxbloxpy.cpython-38-x86_64-linux-gnu.so+0x3891b0)
    #9 0x7f1b4a6c027b in func() /home/h-ishida/cpp/voxbloxpy/wrapper.cpp:30
    #10 0x7f1b4a77a004 in void pybind11::detail::argument_loader<>::call_impl<void, void (*&)(), , pybind11::detail::void_type>(void (*&)(), std::integer_sequence<unsigned long>, pybind11::detail::void_type&&) && (/home/h-ishida/cpp/voxbloxpy/build/_voxbloxpy.cpython-38-x86_64-linux-gnu.so+0x40a004)
    #11 0x7f1b4a766895 in std::enable_if<std::is_void<void>::value, pybind11::detail::void_type>::type pybind11::detail::argument_loader<>::call<void, pybind11::detail::void_type, void (*&)()>(void (*&)()) && (/home/h-ishida/cpp/voxbloxpy/build/_voxbloxpy.cpython-38-x86_64-linux-gnu.so+0x3f6895)
    #12 0x7f1b4a74d637 in pybind11::cpp_function::initialize<void (*&)(), void, , pybind11::name, pybind11::scope, pybind11::sibling>(void (*&)(), void (*)(), pybind11::name const&, pybind11::scope const&, pybind11::sibling const&)::{lambda(pybind11::detail::function_call&)#3}::operator()(pybind11::detail::function_call&) const (/home/h-ishida/cpp/voxbloxpy/build/_voxbloxpy.cpython-38-x86_64-linux-gnu.so+0x3dd637)
    #13 0x7f1b4a74d786 in pybind11::cpp_function::initialize<void (*&)(), void, , pybind11::name, pybind11::scope, pybind11::sibling>(void (*&)(), void (*)(), pybind11::name const&, pybind11::scope const&, pybind11::sibling const&)::{lambda(pybind11::detail::function_call&)#3}::_FUN(pybind11::detail::function_call&) (/home/h-ishida/cpp/voxbloxpy/build/_voxbloxpy.cpython-38-x86_64-linux-gnu.so+0x3dd786)
    #14 0x7f1b4a6efe85 in pybind11::cpp_function::dispatcher(_object*, _object*, _object*) (/home/h-ishida/cpp/voxbloxpy/build/_voxbloxpy.cpython-38-x86_64-linux-gnu.so+0x37fe85)
    #15 0x5f3988 in PyCFunction_Call (/usr/bin/python3.8+0x5f3988)

Direct leak of 106432 byte(s) in 80 object(s) allocated from:
    #0 0x7f1b4f18e808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x5ba023 in PyObject_Malloc (/usr/bin/python3.8+0x5ba023)

Direct leak of 6046 byte(s) in 7 object(s) allocated from:
    #0 0x7f1b4f18e808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x589ef6  (/usr/bin/python3.8+0x589ef6)

Direct leak of 3756 byte(s) in 6 object(s) allocated from:
    #0 0x7f1b4f18e808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x4f08d9  (/usr/bin/python3.8+0x4f08d9)

Direct leak of 1242 byte(s) in 2 object(s) allocated from:
    #0 0x7f1b4f18e808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x5f8a00 in PyBytes_FromStringAndSize (/usr/bin/python3.8+0x5f8a00)

Direct leak of 1152 byte(s) in 2 object(s) allocated from:
    #0 0x7f1b4f18e808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x5d42e7 in PyDict_Copy (/usr/bin/python3.8+0x5d42e7)

Direct leak of 1096 byte(s) in 2 object(s) allocated from:
    #0 0x7f1b4f18e808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x53c017 in _PyObject_GC_NewVar (/usr/bin/python3.8+0x53c017)

Direct leak of 536 byte(s) in 1 object(s) allocated from:
    #0 0x7f1b4f18e808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x5b9597  (/usr/bin/python3.8+0x5b9597)

Indirect leak of 15912 byte(s) in 17 object(s) allocated from:
    #0 0x7f1b4f18e808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x5a9cc6 in PyType_GenericAlloc (/usr/bin/python3.8+0x5a9cc6)

Indirect leak of 4779 byte(s) in 5 object(s) allocated from:
    #0 0x7f1b4f18e808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x4f08d9  (/usr/bin/python3.8+0x4f08d9)

Indirect leak of 2660 byte(s) in 2 object(s) allocated from:
    #0 0x7f1b4f18e808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x589ef6  (/usr/bin/python3.8+0x589ef6)

Indirect leak of 2571 byte(s) in 2 object(s) allocated from:
    #0 0x7f1b4f18e808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x5ba023 in PyObject_Malloc (/usr/bin/python3.8+0x5ba023)

SUMMARY: AddressSanitizer: 17083398 byte(s) leaked in 128 allocation(s).
h-ishida@stone-jsk:~/cpp/voxbloxpy/build$ 

@HiroIshida HiroIshida changed the title bug: address sanitizer found memory leak bug: memory leak on ApproxHashSset Nov 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant