Boost logo

Boost :

Subject: Re: [boost] [threads] Memory leaks in Boost threading support? Version boost_1_53_0
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2013-09-14 09:24:28


Le 14/09/13 03:42, Paul Morrison a écrit :
> I am running a number of Boost threads communicating via bounded
> buffers. My programs seem to run properly, but I get a number of
> memory leaks, usually 4- and 8- byte areas, although a few are
> longer. As far as I can tell, they are coming from inside Boost, as
> there is no mention of lines in my code. OTOH, although my code runs
> fine, it is quite possible that there are subtle errors in it!
>
> I am using _CRTDBG_MAP_ALLOC, which is being used correctly as it
> detected one area of my own that I was not freeing up, and that has
> been fixed.
>
> I am running VC++ 2010 Express on a 64-bit machine.
>
> Here is my memory leak display - I tried setting a few of the numbers
> as breakpoints, using_CrtSetBreakAlloc(), but most of them did not
> cause breaks.
>
> The first one broke at a new in >
> boost::detail::basic_condition_variable::get_wait_entry() Line 180 +
> 0x7 bytes C++
>
> Why wouldn't this get freed up?!
>
> Note: <bad exception > looks ominous - where is it coming from?!
>
Hi,

the issue seems to be introduced in changeset
https://svn.boost.org/trac/boost/changeset/40478 improved lifetime
management of thread data.

-
- struct externally_launched_thread_deleter
- {
- externally_launched_thread* thread_data;
-
- externally_launched_thread_deleter(externally_launched_thread* thread_data_):
- thread_data(thread_data_)
- {}
-
- void operator()() const
- {
- intrusive_ptr_release(thread_data);
- }
- };
-
- }
-
+ }
  
      thread thread::self()
@@ -156,5 +185,4 @@
              externally_launched_thread* me=detail::heap_new<externally_launched_thread>();
              set_current_thread_data(me);
- this_thread::at_thread_exit(externally_launched_thread_deleter(me));
          }
          return thread(boost::intrusive_ptr<detail::thread_data_base>(get_current_thread_data()));
@@ -375,17 +403,4 @@

I would need some time to analyze the changes.

Please could you create a Trac ticket?

Best,
Vicente


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk