[pgrouting-dev] PGR-2: Add some robustness to the boost wrappers

Stephen Woodbridge woodbri at swoodbridge.com
Wed May 15 18:51:30 PDT 2013


Hi all,

I have looking into how to fix issue #32 which has to do with a fatal 
error happening deep in the boost code.

I think we have the info we need to fix this issue in C++ but I need 
some C++ developer help as you already know.

Anyway I have found a simple way to catch these error and without 
crashing the server. In all likelihood, this will cause memory leaks 
which probably will require a graceful server restart, but at least it 
won't be a hard crash like before.

So the pattern for this is to simply wrapt the whole body of any C++ 
code that is called from C with a try-cacth block like:

int my_cpp_function(args...)
{
   try {

     //function body

     return EXIT_SUCCESS;
   }
   catch(...) {
     return -1;
   }
}

So I just added this change to the following files:

src/apsp_johnson/src/apsp_johnson_boost_wrapper.cpp
src/apsp_warshall/src/apsp_boost_wrapper.cpp
src/astar/src/astar_boost_wrapper.cpp
src/dijkstra/src/boost_wrapper.cpp
src/dijkstra/tester/boost_wrapper.cpp
src/driving_distance/src/boost_drivedist.cpp

and my test file for issue #32 now reports:

pgr_test=# SELECT * FROM pgr_dijkstra('SELECT id, source, target, cost 
FROM network', 4401489, 4401483, false, false) ;
ERROR:  Error computing path: Unknown exception caught!

but it does not crash the server.

Progress in small steps!

-Steve


More information about the pgrouting-dev mailing list