Opened 12 months ago

Last modified 9 months ago

#13408 assigned Support Requests

Boost Library Possible memory Leak

Reported by: anonymous Owned by: viboes
Milestone: To Be Determined Component: thread
Version: Boost 1.63.0 Severity: Problem
Keywords: Cc:

Description (last modified by viboes)

Hi,

We have been using Boost library in the project. I've made analysis by using Valgrind tool to be able to find possible memory leaks. According to the result, there is a memory leak in Boost library.

==7535== 24 bytes in 1 blocks are still reachable in loss record 2 of 6
==7535==    at 0x4C2B0E0: operator new(unsigned long)
(vg_replace_malloc.c:324)
==7535==    by 0x4E430A3: boost::detail::make_external_thread_data()
(in /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.55.0)
==7535==    by 0x4E433DB: boost::detail::add_new_tss_node(void const*,
boost::shared_ptr<boost::detail::tss_cleanup_function>, void*)
(in /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.55.0)
==7535==    by 0x4E4408C: boost::detail::set_tss_data(void const*,
boost::shared_ptr<boost::detail::tss_cleanup_function>, void*, bool)
(in /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.55.0)
==7535==    by 0x54CAC0C:
boost::log::v2_mt_posix::core::add_thread_attribute(boost::log::v2_mt_posix::attribute_name const&, boost::log::v2_mt_posix::attribute const&)

It seems like the allocated memory is not deallocated, so it causes memory leak. Here is the definition of relevant event ;

       thread_data_base* make_external_thread_data()
        {
            thread_data_base* const
me(detail::heap_new<externally_launched_thread>());
            me->self.reset(me);
            set_current_thread_data(me);
            return me;
        }


        thread_data_base* get_or_make_current_thread_data()
        {
            thread_data_base*
current_thread_data(get_current_thread_data());
            if(!current_thread_data)
            {
                current_thread_data=make_external_thread_data();
            }
            return current_thread_data;
        }

I've made some research if there is any post which states that this event causes memory leak, but could not find any. Is there any fix for the problem stated above? If there is any, could you please state the relevant patch ?

Thanks in advance,

Kind Regards

Change History (7)

comment:1 Changed 12 months ago by Kohei Takahashi

Component: Nonethread
Owner: set to Anthony Williams

comment:2 Changed 11 months ago by viboes

Description: modified (diff)
Owner: changed from Anthony Williams to viboes

comment:3 Changed 11 months ago by viboes

Are you sure your thread has been joined?

comment:4 Changed 9 months ago by viboes

This is allocated for native threads that are using the Boost.Thread API.

Could you check if the program is calling to tls_destructor before/after doing the report?

extern "C"
            {
                static void tls_destructor(void* data)

Wondering if this isn't associated to some DLL issues.

Last edited 9 months ago by viboes (previous) (diff)

comment:5 Changed 9 months ago by viboes

Status: newassigned

comment:7 Changed 9 months ago by viboes

Type: BugsSupport Requests

Moved to support until we know that the threads are finished and joined before valgrind report.

Note: See TracTickets for help on using tickets.