[Lemon-user] Issue with ListDigraph::NodeMaps

Marco Blanco blanco at zib.de
Mon Jun 12 11:28:45 CEST 2017


Dear Lemon-Team,

I've run across a problem with your ListDigraph::NodeMapswhich I can't 
solve on my own.

Unfortunately, as the code is rather intricate, I find myself unable to 
provide a minimal example, but the simplified structure is as follows: 
The function testcreates a Graph2Dwith an underlying 
lemon::ListDigraphobject and calls a shortestPathwrapper. This 
shortestPathfunction creates a Query2Dobject, which knows the underlying 
ListDigraph, and keeps a few NodeMaps(see below). The first three 
NodeMapsnever caused an issue, but when I implemented the fourth one 
called _potential, the destructor of Graph2Dthrows a segfault. Note that 
none of the destructors are implemented by me, I use the standard 
implicit destructors.

In the attached valgrind output, I could trace the segfault down to the 
clear()function in alteration_notifier.h -- yet, as three 
NodeMapsalready exist and seemingly work fine, I'm at a loss as to why 
this segfault occurs. I'm grateful for any support you can provide!

Regards,
Marco


void test(const Problem& problem)
{
     Graph2D g2D(problem);
     g2D.shortestPath("from","to");
}

class Graph2D
{
public:
     Graph2D(const Problem& problem);
     lemon::ListDigraph G;

     void shortestPath(const std::string& from, const std::string& to)
     lemon::ListDigraph::Node getNode(const std::string& name);
}

void Graph2D::shortestPath(const std::string& from, const std::string& to)
{
     Query2D query(*this);

     lemon::ListDigraph::Node s = getNode(from);
     lemon::ListDigraph::Node t = getNode(to);

     query.run(s,t);
}


class Query2D
{
public:
     Query2D(const Graph2D& g2D);

     const Graph2D* const _bg;
     const lemon::ListDigraph& G;

     void run(lemon::ListDigraph::Node s, lemon::ListDigraph::Node t);

     /** The following three NodeMaps have been here for a long time and 
never caused any issues */
     lemon::ListDigraph::NodeMap<short> _settled;
     lemon::ListDigraph::NodeMap<size_t> _id;
     lemon::ListDigraph::NodeMap<short> _nodeType;

     /** This map causes trouble. If left in, it causes the attached 
SIGSEGV (even though it is never used after initialisation!), if 
commented out, everything works nice and smooth */
     lemon::ListDigraph::NodeMap<double> _potential;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lemon.cs.elte.hu/pipermail/lemon-user/attachments/20170612/0fc6ae63/attachment.html>
-------------- next part --------------
==22776== Invalid free() / delete / delete[] / realloc()
==22776==    at 0x4C2F24B: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22776==    by 0x7AD5F2: deallocate (new_allocator.h:110)
==22776==    by 0x7AD5F2: clear (array_map.h:322)
==22776==    by 0x7AD5F2: ~ArrayMap (array_map.h:163)
==22776==    by 0x7AD5F2: ~DefaultMap (default_map.h:154)
==22776==    by 0x7AD5F2: ~MapExtender (map_extender.h:38)
==22776==    by 0x7AD5F2: ~NodeMap (graph_extender.h:220)
==22776==    by 0x7AD5F2: Query2D::~Query2D()
==22776==    by 0x7BC52F: Graph2D::shortestPath(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) const
==22776==    by 0x6CD2DE: test(Problem const&)
==22776==    by 0x7093D5: Environment::solveProblem()
==22776==    by 0x7095C1: Environment::optimize()
==22776==    by 0x54FFDA: FPEnvironment::optimize()
==22776==    by 0x40C1B1: main (vo_main.cpp:396)
==22776==  Address 0xf4e5cf80 is 0 bytes after a block of size 3,751,744 alloc'd
==22776==    at 0x4C2E0EF: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==22776==    by 0x636168: allocate (new_allocator.h:104)
==22776==    by 0x636168: allocate (alloc_traits.h:491)
==22776==    by 0x636168: _M_allocate (stl_vector.h:170)
==22776==    by 0x636168: std::vector<double, std::allocator<double> >::_M_fill_insert(__gnu_cxx::__normal_iterator<double*, std::vector<double, std::allocator<double> > >, unsigned long, double const&) (vector.tcc:491)
==22776==    by 0x7B7843: insert (stl_vector.h:1054)
==22776==    by 0x7B7843: resize (stl_vector.h:696)
==22776==    by 0x7B7843: VectorMap (vector_map.h:103)
==22776==    by 0x7B7843: DefaultMap (default_map.h:166)
==22776==    by 0x7B7843: MapExtender (map_extender.h:66)
==22776==    by 0x7B7843: NodeMap (graph_extender.h:228)
==22776==    by 0x7B7843: Query2D::Query2D(Graph2D const&)
==22776==    by 0x7BC148: Graph2D::shortestPath(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) const
==22776==    by 0x6CD2DE: test(fp::Problem const&)
==22776==    by 0x7093D5: Environment::solveProblem()
==22776==    by 0x7095C1: Environment::optimize()
==22776==    by 0x54FFDA: FPEnvironment::optimize()
==22776==    by 0x40C1B1: main
==22776== 
==22776== Invalid read of size 8
==22776==    at 0x4B1044: clear (alteration_notifier.h:459)
==22776==    by 0x4B1044: lemon::DigraphExtender<lemon::ListDigraphBase>::~DigraphExtender() (graph_extender.h:323)
==22776==    by 0x6CD680: ~Graph2D
==22776==    by 0x6CD680: test(Problem const&)
==22776==    by 0x7093D5: Environment::solveProblem()
==22776==    by 0x7095C1: Environment::optimize()
==22776==    by 0x54FFDA: FPEnvironment::optimize()
==22776==    by 0x40C1B1: main
==22776==  Address 0xffeffaac0 is on thread 1's stack
==22776==  368 bytes below stack pointer
==22776== 
==22776== Invalid read of size 8
==22776==    at 0x4B1047: clear (alteration_notifier.h:459)
==22776==    by 0x4B1047: lemon::DigraphExtender<lemon::ListDigraphBase>::~DigraphExtender() (graph_extender.h:323)
==22776==    by 0x6CD680: ~Graph2D
==22776==    by 0x6CD680: test(Problem const&)
==22776==    by 0x7093D5: Environment::solveProblem()
==22776==    by 0x7095C1: Environment::optimize()
==22776==    by 0x54FFDA: FPEnvironment::optimize()
==22776==    by 0x40C1B1: main
==22776==  Address 0x38 is not stack'd, malloc'd or (recently) free'd
==22776== 
==22776== 
==22776== Process terminating with default action of signal 11 (SIGSEGV)
==22776==  Access not within mapped region at address 0x38
==22776==    at 0x4B1047: clear (alteration_notifier.h:459)
==22776==    by 0x4B1047: lemon::DigraphExtender<lemon::ListDigraphBase>::~DigraphExtender() (graph_extender.h:323)
==22776==    by 0x6CD680: ~Graph2D
==22776==    by 0x6CD680: test(Problem const&)
==22776==    by 0x7093D5: Environment::solveProblem()
==22776==    by 0x7095C1: Environment::optimize()
==22776==    by 0x54FFDA: FPEnvironment::optimize()
==22776==    by 0x40C1B1: main
==22776==  If you believe this happened as a result of a stack
==22776==  overflow in your program's main thread (unlikely but
==22776==  possible), you can try to increase the size of the
==22776==  main thread stack using the --main-stacksize= flag.
==22776==  The main thread stack size used in this run was 8388608.
==22776== 
==22776== HEAP SUMMARY:
==22776==     in use at exit: 1,625,068,408 bytes in 18,818,947 blocks
==22776==   total heap usage: 256,063,868 allocs, 237,244,922 frees, 15,608,496,497 bytes allocated
==22776== 
==22776== LEAK SUMMARY:
==22776==    definitely lost: 5,851,168 bytes in 3 blocks
==22776==    indirectly lost: 4,761 bytes in 78 blocks
==22776==      possibly lost: 0 bytes in 0 blocks
==22776==    still reachable: 1,619,212,479 bytes in 18,818,866 blocks
==22776==         suppressed: 0 bytes in 0 blocks
==22776== Rerun with --leak-check=full to see details of leaked memory
==22776== 
==22776== For counts of detected and suppressed errors, rerun with: -v
==22776== ERROR SUMMARY: 3 errors from 3 contexts (suppressed: 0 from 0)


More information about the Lemon-user mailing list