Boost C++ Libraries: Ticket #3078: Assert failure caused by property_map with BGL bundled properties if compiled in Debug mode in VS2008 SP1 https://svn.boost.org/trac10/ticket/3078 <p> The program attached compiles in Debug but causes an assertion failure if the graph contains bundled properties. The same code was tested with no properties attached to vertices/edges and no errors were observed. </p> <p> Here is the error: </p> <p> vector, line 160. Assertion Failed: Expression("this-&gt;_Has_container()", 0) </p> <p> This corresponds to the earlier call to a function on line 351 in property_map.hpp: </p> <p> inline R operator[](key_type v) const { return *(iter + get(index, v)) ; } </p> <p> Full stack frame from this call is: </p> <p> <em></em><em></em><em></em><em></em><em></em><em></em> </p> <p> std::_Vector_const_iterator&lt;unsigned int,std::allocator&lt;unsigned int&gt; &gt;::operator+=(int _Off=47) Line 160 </p> <p> std::_Vector_iterator&lt;unsigned int,std::allocator&lt;unsigned int&gt; &gt;::operator+=(int _Off=47) Line 376 </p> <p> std::_Vector_iterator&lt;unsigned int,std::allocator&lt;unsigned int&gt; &gt;::operator+(int _Off=47) Line 382 </p> <blockquote class="citation"> </blockquote> <p> boost::iterator_property_map&lt;std::_Vector_iterator&lt;unsigned int,std::allocator&lt;unsigned int&gt; &gt;,boost::vec_adj_list_vertex_id_map&lt;boost::property&lt;enum boost::vertex_bundle_t,Clip_t,boost::no_property&gt;,unsigned int&gt;,unsigned int,unsigned int &amp;&gt;::operator[](unsigned int v=47) Line 351 </p> <p> boost::put&lt;boost::iterator_property_map&lt;std::_Vector_iterator&lt;unsigned int,std::allocator&lt;unsigned int&gt; &gt;,boost::vec_adj_list_vertex_id_map&lt;boost::property&lt;enum boost::vertex_bundle_t,Clip_t,boost::no_property&gt;,unsigned int&gt;,unsigned int,unsigned int &amp;&gt;,unsigned int &amp;,unsigned int,unsigned int&gt;(const boost::put_get_helper&lt;unsigned int &amp;,boost::iterator_property_map&lt;std::_Vector_iterator&lt;unsigned int,std::allocator&lt;unsigned int&gt; &gt;,boost::vec_adj_list_vertex_id_map&lt;boost::property&lt;enum boost::vertex_bundle_t,Clip_t,boost::no_property&gt;,unsigned int&gt;,unsigned int,unsigned int &amp;&gt; &gt; &amp; pa={...}, unsigned int k=47, const unsigned int &amp; v=27) Line 321 </p> <p> <em></em><em></em><em></em><em></em><em></em><em></em> </p> <p> This happens if program is compiled on VS2008 SP1 in DEBUG mode. If compiled in Release mode, program works as expected with no errors (atleast none that I can see). The program uses boost 1.38.0. </p> <p> Arty </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/3078 Trac 1.4.3 Artyom Arabadji <sneg.vx@…> Mon, 25 May 2009 11:34:11 GMT attachment set https://svn.boost.org/trac10/ticket/3078 https://svn.boost.org/trac10/ticket/3078 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">BGLTest.cpp</span> </li> </ul> <p> example to reproduce the rpoblem </p> Ticket Artyom Arabadji <sneg.vx@…> Mon, 25 May 2009 11:57:06 GMT attachment set https://svn.boost.org/trac10/ticket/3078 https://svn.boost.org/trac10/ticket/3078 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">BGLTest.2.cpp</span> </li> </ul> <p> example to reproduce the problem (updated) </p> Ticket Jeremiah Willcock Mon, 25 May 2009 18:18:14 GMT <link>https://svn.boost.org/trac10/ticket/3078#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3078#comment:1</guid> <description> <p> This code is syntactically invalid. I fixed those issues but could not reproduce the problem under Valgrind on Linux. The GCC debug mode doesn't work on this code for unrelated reasons. I don't have access to VC 10. Do you have a simpler version that exhibits the problem? Please at least remove the randomness and unrelated code. </p> </description> <category>Ticket</category> </item> <item> <author>Artyom Arabadji <sneg.vx@…></author> <pubDate>Mon, 25 May 2009 19:55:45 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/3078#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3078#comment:2</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/3078#comment:1" title="Comment 1">jewillco</a>: </p> <blockquote class="citation"> <p> This code is syntactically invalid. I fixed those issues but could not reproduce the problem under Valgrind on Linux. The GCC debug mode doesn't work on this code for unrelated reasons. I don't have access to VC 10. Do you have a simpler version that exhibits the problem? Please at least remove the randomness and unrelated code. </p> </blockquote> <p> I just made a simpler example but the error didn't appear... Perhaps this is something compiler-dependent? Could you please attach your version that you tested on Linux with my errors fixed so I can have a look? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Jeremiah Willcock</dc:creator> <pubDate>Mon, 25 May 2009 20:01:34 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/3078 https://svn.boost.org/trac10/ticket/3078 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">BGLTest.3.cpp</span> </li> </ul> <p> Fixed version of test </p> Ticket Jeremiah Willcock Mon, 25 May 2009 20:03:10 GMT <link>https://svn.boost.org/trac10/ticket/3078#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3078#comment:3</guid> <description> <p> I attached that. It is compiler-dependent; I think VC 10's debug mode is like the GLibC++ debug mode that I can't get working because of Phoenix problems. Is there a simpler version that fails on VC 10? </p> </description> <category>Ticket</category> </item> <item> <author>Artyom Arabadji <sneg.vx@…></author> <pubDate>Mon, 25 May 2009 20:53:20 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/3078#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3078#comment:4</guid> <description> <p> Sorry about the errors, it compiled fine on Windows and I didn't test on Linux. I took your version and tried to simplify it a bit. It seems that even without bundled properties the error occurs. </p> </description> <category>Ticket</category> </item> <item> <author>Artyom Arabadji <sneg.vx@…></author> <pubDate>Mon, 25 May 2009 20:54:05 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/3078 https://svn.boost.org/trac10/ticket/3078 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">BGLTest.4.cpp</span> </li> </ul> <p> Simplified version </p> Ticket Jeremiah Willcock Mon, 25 May 2009 21:33:18 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/3078#comment:5 https://svn.boost.org/trac10/ticket/3078#comment:5 <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> There are two issues with your code. The first one, that I think is causing your problem, is that you define a copy constructor that is empty and thus does not copy anything. Therefore, your graph and edge list are not copied when your visitor is passed into depth_first_visit (which is done by copy), leading to the edge list being empty and thus the iterator in your property map being invalid. The second issue is that you are storing the graph by copy in your visitor. This wastes memory, and also (although this may not show up with your graph type) some graph types have vertex descriptors that are tied to a particular graph. For example, using vertices from one graph to access edges or properties in a copy of that graph is invalid (and fails in subtle ways) for some instantiations of adjacency_list. I actually noticed the copy constructor issue when I went to store the graph by reference and the compiler complained about the copy constructor. </p> <p> You should fix your problem in two ways: </p> <ol><li>Change <a class="missing wiki">PathRecorder</a> to store "const Graph&amp;" rather than "const Graph". </li><li>Remove the copy constructor and let the compiler-generated one (which works) be used, or add an explicit copy or reference of the edge data. Note that you may not want to do the default deep copy of that data; you might want to build the property map externally and only store it (and not its underlying data) in your visitor since property maps are copied shallowly. </li></ol> Ticket Artyom Arabadji <sneg.vx@…> Mon, 25 May 2009 21:53:12 GMT <link>https://svn.boost.org/trac10/ticket/3078#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3078#comment:6</guid> <description> <p> Thanks a lot for your help, jewillco. Sorry for submitting invalid bug report. </p> </description> <category>Ticket</category> </item> </channel> </rss>