Boost C++ Libraries: Ticket #2338: sp_collector.cpp reports reachable objects as unreachable https://svn.boost.org/trac10/ticket/2338 <p> Jim Barry in <a class="ext-link" href="http://lists.boost.org/boost-users/2008/09/40507.php"><span class="icon">​</span>http://lists.boost.org/boost-users/2008/09/40507.php</a>: </p> <pre class="wiki">I am trying to detect circular references using the find_unreachable_objects function in sp_collector.cpp. However, it reports false positives in the simple case of one object being owned by another. To illustrate: #define BOOST_SP_ENABLE_DEBUG_HOOKS #include &lt;boost/shared_ptr.hpp&gt; // sp_collector.cpp exported functions std::size_t find_unreachable_objects(bool report); struct X {}; struct Y { boost::shared_ptr&lt;X&gt; pX; Y() : pX(new X) {} }; int main() { boost::shared_ptr&lt;Y&gt; y(new Y); find_unreachable_objects(true); return 0; } The output is as follows: ... 2 objects in m. ... 1 objects in m2. ... 1 objects in open. Unreachable object at 0036BA60, 12 bytes long. Clearly this is incorrect as there are no circular references. Looking at the code, there is what appears to be a typo at line 124: std::cout &lt;&lt; "... " &lt;&lt; m2.size() &lt;&lt; " objects in open.\n"; should be: std::cout &lt;&lt; "... " &lt;&lt; open.size() &lt;&lt; " objects in open.\n"; But the real problem seems to be at line 121: if(p-&gt;use_count() != i-&gt;second) open.push_back(p); I'm not entirely sure what's going on in this section of code, but it ends up determining (incorrectly) that the "X" object is unreachable. </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/2338 Trac 1.4.3 Peter Dimov Wed, 17 Sep 2008 22:12:32 GMT status changed https://svn.boost.org/trac10/ticket/2338#comment:1 https://svn.boost.org/trac10/ticket/2338#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> Ticket Peter Dimov Wed, 17 Sep 2008 22:17:30 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/2338#comment:2 https://svn.boost.org/trac10/ticket/2338#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/48832" title="Fix #2338.">[48832]</a>) Fix <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2338" title="#2338: Bugs: sp_collector.cpp reports reachable objects as unreachable (closed: fixed)">#2338</a>. </p> Ticket