boostorg / graph

Boost.org graph module
http://boost.org/libs/graph
316 stars 202 forks source link

examples crash when run #148

Open jzmaddock opened 5 years ago

jzmaddock commented 5 years ago

The following two examples crash at runtime:

astar_maze.cpp kevin-bacon2.cpp

Sorry but I don't see what the issue is off hand.

jzmaddock commented 5 years ago

Need to add last-mod-time.cpp to this list as well (msvc-12.0).

deinst commented 5 years ago

astar_maze works for me (osx) last-mod-time has problems with the stat call on osx (non fatal, but incorrect results). This would be easiest to fix by using the c++17 filesystem header, is that permissible?

jzmaddock commented 5 years ago

astar_maze works for me (osx)

Works for me on Ubuntu - it's just msvc where it's crashing.

Here's what I've found:

So at this point I'm stumped.

jzmaddock commented 5 years ago

last-mod-time has problems with the stat call on osx (non fatal, but incorrect results). This would be easiest to fix by using the c++17 filesystem header, is that permissible?

Ooops looks like I added that one to the wrong bug report: the example uses several unix-isms which will never compile on windows. So yes, either or <boost/filesystem.hpp> would be good choices IMO.

deinst commented 5 years ago

astar_maze works for me (osx)

Even valgrind is not complaining, so I cannot test anything. I think llvm has similar tools to msvc, and I'll try to figure out what they are.

In the mean time, one thing that smells funny to me is the constructors of the member of maze. The initialization of m_barrier_grid calls create_barrier_grid which uses m_barriers which is initialized after barrier_grid, and so is uinititialized during the call to create_barrier_grid.

If this is the problem, then swapping lines 123 and 125 (the definitions of m_barrier_grid and m_barrier) so that m_barrier is constructed first should fix things.

jzmaddock commented 5 years ago

OK, there is a bug somewhere, but it's masked by some very clever named-return-value optimisations with gcc and clang. Here's what I have so far:

jzmaddock commented 5 years ago

Making filtered_graph_base non-copyable breaks a lot of code - there are a lot of factory functions that create filtered_graph's. filter_graph is actually documented to store a reference and mentions that care should be taken with it's use, but that still didn't stop the authors from falling into this trap.

In the mean time I have an easy fix for astar_maze.cpp which I'll push shortly...

jzmaddock commented 5 years ago

Pushed fixes for astar_maze.cpp: https://github.com/boostorg/graph/commit/32bc0e1dff9554e179f54cb287af9a5541359a25