Opened 13 years ago

Closed 13 years ago

#3296 closed Bugs (invalid)

Small leak using boost::shared_mutex

Reported by: p.minervini@… Owned by: Anthony Williams
Milestone: Boost 1.40.0 Component: thread
Version: Boost 1.39.0 Severity: Problem
Keywords: shared_mutex mutex thread leak Cc: p.minervini@…

Description

I've attached a code sample to reproduce the problem.

Compile and execute with:

g++ test.cpp -o test -lboost_thread

valgrind --leak-check=full --show-reachable=yes ./test

Attachments (1)

test.cpp (939 bytes ) - added by p.minervini@… 13 years ago.
small code snippet to reproduce the problem with boost::shared_mutex

Download all attachments as: .zip

Change History (4)

by p.minervini@…, 13 years ago

Attachment: test.cpp added

small code snippet to reproduce the problem with boost::shared_mutex

comment:1 by anonymous, 13 years ago

I'm on Debian Squeeze, and this is Valgrind's output:

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 OpenWorks 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<void (*)()>(boost::once_flag&, 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<boost::shared_mutex>::lock() (in /home/pasquale/gsoc/test/test) ==19839== by 0x8049E61: boost::upgrade_lock<boost::shared_mutex>::upgrade_lock(boost::shared_mutex&) (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.

comment:2 by anonymous, 13 years ago

this other small snippet is enough to reproduce the problem:

#include <boost/thread.hpp>

#include <boost/thread/shared_mutex.hpp>

#include <boost/thread/locks.hpp>

int main() {

boost::shared_mutex _m;

{

boost::upgrade_lock<boost::shared_mutex> lock(_m);

}

return(0);

}

comment:3 by Steven Watanabe, 13 years ago

Resolution: invalid
Status: newclosed

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.

Note: See TracTickets for help on using tickets.