Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#3078 closed Bugs (invalid)

Assert failure caused by property_map with BGL bundled properties if compiled in Debug mode in VS2008 SP1

Reported by: Artyom Arabadji <sneg.vx@…> Owned by: Douglas Gregor
Milestone: Component: property_map
Version: Boost 1.38.0 Severity: Problem
Keywords: bgl, property_map, vs2008 Cc:

Description

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.

Here is the error:

vector, line 160. Assertion Failed: Expression("this->_Has_container()", 0)

This corresponds to the earlier call to a function on line 351 in property_map.hpp:

inline R operator[](key_type v) const { return *(iter + get(index, v)) ; }

Full stack frame from this call is:

std::_Vector_const_iterator<unsigned int,std::allocator<unsigned int> >::operator+=(int _Off=47) Line 160

std::_Vector_iterator<unsigned int,std::allocator<unsigned int> >::operator+=(int _Off=47) Line 376

std::_Vector_iterator<unsigned int,std::allocator<unsigned int> >::operator+(int _Off=47) Line 382

boost::iterator_property_map<std::_Vector_iterator<unsigned int,std::allocator<unsigned int> >,boost::vec_adj_list_vertex_id_map<boost::property<enum boost::vertex_bundle_t,Clip_t,boost::no_property>,unsigned int>,unsigned int,unsigned int &>::operator[](unsigned int v=47) Line 351

boost::put<boost::iterator_property_map<std::_Vector_iterator<unsigned int,std::allocator<unsigned int> >,boost::vec_adj_list_vertex_id_map<boost::property<enum boost::vertex_bundle_t,Clip_t,boost::no_property>,unsigned int>,unsigned int,unsigned int &>,unsigned int &,unsigned int,unsigned int>(const boost::put_get_helper<unsigned int &,boost::iterator_property_map<std::_Vector_iterator<unsigned int,std::allocator<unsigned int> >,boost::vec_adj_list_vertex_id_map<boost::property<enum boost::vertex_bundle_t,Clip_t,boost::no_property>,unsigned int>,unsigned int,unsigned int &> > & pa={...}, unsigned int k=47, const unsigned int & v=27) Line 321

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.

Arty

Attachments (4)

BGLTest.cpp (9.8 KB ) - added by Artyom Arabadji <sneg.vx@…> 13 years ago.
example to reproduce the rpoblem
BGLTest.2.cpp (10.3 KB ) - added by Artyom Arabadji <sneg.vx@…> 13 years ago.
example to reproduce the problem (updated)
BGLTest.3.cpp (10.3 KB ) - added by Jeremiah Willcock 13 years ago.
Fixed version of test
BGLTest.4.cpp (4.8 KB ) - added by Artyom Arabadji <sneg.vx@…> 13 years ago.
Simplified version

Download all attachments as: .zip

Change History (10)

by Artyom Arabadji <sneg.vx@…>, 13 years ago

Attachment: BGLTest.cpp added

example to reproduce the rpoblem

by Artyom Arabadji <sneg.vx@…>, 13 years ago

Attachment: BGLTest.2.cpp added

example to reproduce the problem (updated)

comment:1 by Jeremiah Willcock, 13 years ago

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.

in reply to:  1 comment:2 by Artyom Arabadji <sneg.vx@…>, 13 years ago

Replying to jewillco:

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.

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?

by Jeremiah Willcock, 13 years ago

Attachment: BGLTest.3.cpp added

Fixed version of test

comment:3 by Jeremiah Willcock, 13 years ago

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?

comment:4 by Artyom Arabadji <sneg.vx@…>, 13 years ago

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.

by Artyom Arabadji <sneg.vx@…>, 13 years ago

Attachment: BGLTest.4.cpp added

Simplified version

comment:5 by Jeremiah Willcock, 13 years ago

Resolution: invalid
Status: newclosed

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.

You should fix your problem in two ways:

  1. Change PathRecorder to store "const Graph&" rather than "const Graph".
  2. 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.

comment:6 by Artyom Arabadji <sneg.vx@…>, 13 years ago

Thanks a lot for your help, jewillco. Sorry for submitting invalid bug report.

Note: See TracTickets for help on using tickets.