|
Boost : |
Subject: [boost] [thread] Memory leak in Boost.Thread?
From: Denis Arnaud (denis.arnaud_boost_at_[hidden])
Date: 2010-08-27 05:59:49
Hello,
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.
Following is a code snippet allowing to reproduce the issue:
====================================
#include <boost/thread.hpp>
void someWork() {
double a;
for(int i= 0;i< 1000;i++) {
a+=log((double)i);
}
}
int main() {
for(int i = 0; i< 10; ++i) {
boost::thread_group pool;
for(int j = 0; j< 100; ++j) {
pool.create_thread(someWork);
}
pool.join_all();
}
}
====================================
Then, following is Valgrind's report:
====================================
==6442== Memcheck, a memory error detector
==6442== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.
==6442== Using Valgrind-3.5.0 and LibVEX; rerun with -h for copyright info
==6442== Command: ./boost_leak
==6442==
==6442==
==6442== HEAP SUMMARY:
==6442== in use at exit: 8 bytes in 1 blocks
==6442== total heap usage: 5,967 allocs, 5,966 frees, 701,720 bytes
allocated
==6442==
==6442== 8 bytes in 1 blocks are still reachable in loss record 1 of 1
==6442== at 0x4C2615D: malloc (vg_replace_malloc.c:195)
==6442== by 0x4E3F989: boost::detail::get_once_per_thread_epoch() (in
/usr/lib64/libboost_thread-mt.so.1.44.0)
==6442== by 0x4E39923: ??? (in /usr/lib64/libboost_thread-mt.so.1.44.0)
==6442== by 0x4E39BC8: boost::detail::get_current_thread_data() (in
/usr/lib64/libboost_thread-mt.so.1.44.0)
==6442== by 0x4E3A528: boost::this_thread::interruption_enabled() (in
/usr/lib64/libboost_thread-mt.so.1.44.0)
==6442== by 0x4E3A548:
boost::this_thread::disable_interruption::disable_interruption() (in
/usr/lib64/libboost_thread-mt.so.1.44.0)
==6442== by 0x404DC4: boost::shared_mutex::lock() (in /tmp/boost_leak)
==6442== by 0x40588D:
boost::lock_guard<boost::shared_mutex>::lock_guard(boost::shared_mutex&) (in
/tmp/boost_leak)
==6442== by 0x405DB5: boost::thread*
boost::thread_group::create_thread<void (*)()>(void (*)()) (in
/tmp/boost_leak)
==6442== by 0x403B91: main (in /tmp/boost_leak)
==6442==
==6442== LEAK SUMMARY:
==6442== definitely lost: 0 bytes in 0 blocks
==6442== indirectly lost: 0 bytes in 0 blocks
==6442== possibly lost: 0 bytes in 0 blocks
==6442== still reachable: 8 bytes in 1 blocks
==6442== suppressed: 0 bytes in 0 blocks
==6442==
==6442== For counts of detected and suppressed errors, rerun with: -v
==6442== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 6 from 6)
====================================
Is that really a memory leak?
Kind Regards
Denis
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk