|
Boost : |
Subject: Re: [boost] [thread] Memory leak in Boost.Thread?
From: Denis Arnaud (denis.arnaud_boost_at_[hidden])
Date: 2010-10-03 07:16:48
2010/9/30 <boost-request_at_[hidden]>
> Date: Wed, 29 Sep 2010 15:17:40 -0400
> From: Frank Mori Hess <frank.hess_at_[hidden]>
>
> > > a Fedora user has reported a potential memory leak in Boost.Thread (see
> > > https://bugzilla.redhat.com/show_bug.cgi?id=627875 for details),
> detected
> > > with Valgrind in (at least) versions 1.41.0 and 1.44.0.
> >
> > Apparently, as per https://bugzilla.redhat.com/show_bug.cgi?id=627875#c7,
> > it seems there is a bug in Boost Thread.
> >
> > As I'm not a specialist in that area, I prefer to hand it over to more
> > savvy developers on the list. Do not hesitate to answer directly on
> > Bugzilla.
>
> As far as I can tell, the "fix" for this "bug" is to insure some per-thread
> memory is freed just before the entire program exits? The only point to
> doing that would be to quiet valgrind.
>
Maybe the reason posix threads don't invoke their per-thread data
> destructors is that it is pointless? I mean to say they don't invoke when
> the thread is killed due to the
> main thread exiting.
>
What do you think of Bart's suggestion in
https://bugzilla.redhat.com/show_bug.cgi?id=627875#c9 (i.e., adding "some
comments in the two source files
libs/thread/src/pthread/once.<https://svn.boost.org/trac/boost/browser/trunk/libs/thread/src/pthread/once.cpp>
cpp<https://svn.boost.org/trac/boost/browser/trunk/libs/thread/src/pthread/once.cpp>and
libs/thread/src/pthread/<https://svn.boost.org/trac/boost/browser/trunk/libs/thread/src/pthread/thread.cpp>
thread.cpp<https://svn.boost.org/trac/boost/browser/trunk/libs/thread/src/pthread/thread.cpp>,
that even when an application exit()s normally it is possible that the
destructor is not invoked, together with the a reference to the POSIX specs
that explain this behavior, e.g.,
http://opengroup.org/onlinepubs/9699919799/functions/_Exit.html#tag_16_01_03_01
)?
I've looked into the Gmane archive of the Boost developer list (
http://search.gmane.org/?query=thread+memory+leak&group=gmane.comp.lib.boost.devel),
and that issue has been raised several times during (at least) the last six
years, with sometimes the same recommendation: to add some comments in the
source code. For instance,
http://thread.gmane.org/gmane.comp.lib.boost.devel/145329/focus=145333,
http://thread.gmane.org/gmane.comp.lib.boost.devel/96846/focus=97232,
http://thread.gmane.org/gmane.comp.lib.boost.devel/187881/focus=187893.
Regards
Denis
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk