Boost C++ Libraries: Ticket #3296: Small leak using boost::shared_mutex https://svn.boost.org/trac10/ticket/3296 <p> I've attached a code sample to reproduce the problem. </p> <p> Compile and execute with: </p> <p> g++ test.cpp -o test -lboost_thread </p> <p> valgrind --leak-check=full --show-reachable=yes ./test </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/3296 Trac 1.4.3 p.minervini@… Tue, 28 Jul 2009 16:18:34 GMT attachment set https://svn.boost.org/trac10/ticket/3296 https://svn.boost.org/trac10/ticket/3296 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">test.cpp</span> </li> </ul> <p> small code snippet to reproduce the problem with boost::shared_mutex </p> Ticket anonymous Tue, 28 Jul 2009 20:19:25 GMT <link>https://svn.boost.org/trac10/ticket/3296#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3296#comment:1</guid> <description> <p> I'm on Debian Squeeze, and this is Valgrind's output: </p> <p> pasquale@dell:~/gsoc/test$ valgrind --leak-check=full --show-reachable=yes ./test ==19839== Memcheck, a memory error detector. ==19839== Copyright (C) 2002-2008, and GNU GPL'd, by Julian Seward et al. ==19839== Using LibVEX rev 1884, a library for dynamic binary translation. ==19839== Copyright (C) 2004-2008, and GNU GPL'd, by <a class="missing wiki">OpenWorks</a> LLP. ==19839== Using valgrind-3.4.1-Debian, a dynamic binary instrumentation framework. ==19839== Copyright (C) 2000-2008, and GNU GPL'd, by Julian Seward et al. ==19839== For more details, rerun with: -v ==19839== ==19839== ==19839== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 23 from 1) ==19839== malloc/free: in use at exit: 8 bytes in 1 blocks. ==19839== malloc/free: 2 allocs, 1 frees, 12 bytes allocated. ==19839== For counts of detected errors, rerun with: -v ==19839== searching for pointers to 1 not-freed blocks. ==19839== checked 122,096 bytes. ==19839== ==19839== 8 bytes in 1 blocks are still reachable in loss record 1 of 1 ==19839== at 0x402601E: malloc (vg_replace_malloc.c:207) ==19839== by 0x4078E7B: boost::detail::get_once_per_thread_epoch() (once.cpp:43) ==19839== by 0x4075153: void boost::call_once&lt;void (*)()&gt;(boost::once_flag&amp;, void (*)()) (once.hpp:50) ==19839== by 0x4071EF9: boost::detail::get_current_thread_data() (thread.cpp:108) ==19839== by 0x4072166: boost::this_thread::interruption_enabled() (thread.cpp:488) ==19839== by 0x4072196: boost::this_thread::disable_interruption::disable_interruption() (thread.cpp:507) ==19839== by 0x8049CF2: boost::shared_mutex::lock_upgrade() (in /home/pasquale/gsoc/test/test) ==19839== by 0x8049E33: boost::upgrade_lock&lt;boost::shared_mutex&gt;::lock() (in /home/pasquale/gsoc/test/test) ==19839== by 0x8049E61: boost::upgrade_lock&lt;boost::shared_mutex&gt;::upgrade_lock(boost::shared_mutex&amp;) (in /home/pasquale/gsoc/test/test) ==19839== by 0x8049354: Test::Instance() (in /home/pasquale/gsoc/test/test) ==19839== by 0x804940F: main (in /home/pasquale/gsoc/test/test) ==19839== ==19839== LEAK SUMMARY: ==19839== definitely lost: 0 bytes in 0 blocks. ==19839== possibly lost: 0 bytes in 0 blocks. ==19839== still reachable: 8 bytes in 1 blocks. ==19839== suppressed: 0 bytes in 0 blocks. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Wed, 29 Jul 2009 12:12:45 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/3296#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3296#comment:2</guid> <description> <p> this other small snippet is enough to reproduce the problem: </p> <p> #include &lt;boost/thread.hpp&gt; </p> <p> #include &lt;boost/thread/shared_mutex.hpp&gt; </p> <p> #include &lt;boost/thread/locks.hpp&gt; </p> <p> int main() { </p> <blockquote> <p> boost::shared_mutex _m; </p> </blockquote> <blockquote> <blockquote> <p> { </p> </blockquote> </blockquote> <blockquote> <blockquote> <blockquote> <p> boost::upgrade_lock&lt;boost::shared_mutex&gt; lock(_m); </p> </blockquote> </blockquote> </blockquote> <blockquote> <blockquote> <p> } </p> </blockquote> </blockquote> <p> </p> <blockquote> <p> return(0); </p> </blockquote> <p> } </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Steven Watanabe</dc:creator> <pubDate>Fri, 21 Aug 2009 13:51:43 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/3296#comment:3 https://svn.boost.org/trac10/ticket/3296#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> <p> This is not a bug. A pointer is stored in thread specific storage and this pointer is supposed to be freed when the thread exits. </p> Ticket