id,summary,reporter,owner,description,type,status,milestone,component,version,severity,resolution,keywords,cc 5754,Bug/design issue with boost::thread::id,ZenJu ,viboes,"Hi, I have just run into a nasty memory leak which was caused by a circular reference due to boost::thread::id. The situation is as follows: 1. Main thread controls several worker thread. 2. Only one worker thread shall be allowed to report its current status, so we need some identifier. 3. The information which thread shall report, is placed as a boost::thread::id into a structure which is shared by main thread and all worker threads (via std::shared_ptr) 4. We happily and unwittingly(!) introduced a circular reference! Analysis: Main thread successfully joins all worker threads, still there is a circular reference. Simple reason: boost::thread::id has partial ownership of the corresponding thread local storage! Technically it's implemented as an intrusive_ptr on boost::detail::thread_data which owns the TLS, in my case it's the data of a full blown function object, which I had passed to boost::thread. In the example above, one of the worker threads shares ownership to the shared structure containing a thread::id which shares ownership of...surprise ...himself! This is IMHO a design bug! A thread::id should not have any ownership of its corresponding thread's data, but should be a plain vanilla value type without any side-effects. Fix is simple, just remove the thread::id's ownership semantics. I really hope this gets addresses (soon), since it's fundamental, and IMHO in contrast to reasonable expectations. Tested with boost v1.47 on MingW/GCC and VC 2010 64-bit Best regards, ZenJu",Bugs,closed,To Be Determined,thread,Boost 1.47.0,Showstopper,duplicate,thread::id,viboes