From: curt Date: Wed, 19 May 1999 20:01:53 +0000 (+0000) Subject: Better error catching and recovery when our input sends the triangulator X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=5d8d7bc6870c6ae8145b02e9f72fb778a23c708e;p=flightgear.git Better error catching and recovery when our input sends the triangulator into never, never land. --- diff --git a/Tools/Construct/Main/main.cxx b/Tools/Construct/Main/main.cxx index 98bc9c765..5923625e5 100644 --- a/Tools/Construct/Main/main.cxx +++ b/Tools/Construct/Main/main.cxx @@ -24,6 +24,10 @@ #include // for directory reading #include // for directory reading +#include // set mem allocation limit +#include // set mem allocation limit +#include // set mem allocation limit + #include #include #include @@ -393,23 +397,34 @@ void construct_tile( FGConstruct& c ) { << endl; } - if ( (count > c.get_max_nodes()) && (error <= 1000.0) ) { - // increase error tolerance until number of points drops below - // the maximum threshold - cout << "produced too many nodes ..." << endl; + if ( count > c.get_max_nodes() ) { + if ( error <= 1000.0 ) { + // increase error tolerance until number of points drops below + // the maximum threshold + cout << "produced too many nodes ..." << endl; - acceptable = false; - shrinking = true; + acceptable = false; + shrinking = true; + + if ( growing ) { + error *= 1.25; + growing = false; + } else { + error *= 1.5; + } - if ( growing ) { - error *= 1.25; - growing = false; + cout << "Setting error to " << error << " and retrying fit." + << endl; } else { - error *= 1.5; + // we tried, but can't seem to get down to a + // reasonable number of points even with a huge error + // tolerance. This could be related to the triangle() + // call which might be having trouble with our input + // set. Let's just die hope that our parent can try + // again with a smaller interior triangle angle. + cout << "Error: Too many nodes." << endl; + exit(-1); } - - cout << "Setting error to " << error << " and retrying fit." - << endl; } } @@ -478,6 +493,30 @@ main(int argc, char **argv) { usage( argv[0] ); } + // set mem allocation limit. Reason: occasionally the triangle() + // routine can blow up and allocate memory forever. We'd like + // this process to die before things get out of hand so we can try + // again with a smaller interior angle limit. + int result; + struct rlimit limit; + limit.rlim_cur = 20000000; + limit.rlim_max = 20000000; + result = setrlimit( RLIMIT_DATA, &limit ); + cout << "result of setting mem limit = " << result << endl; + result = setrlimit( RLIMIT_STACK, &limit ); + cout << "result of setting mem limit = " << result << endl; + result = setrlimit( RLIMIT_CORE, &limit ); + cout << "result of setting mem limit = " << result << endl; + result = setrlimit( RLIMIT_RSS, &limit ); + cout << "result of setting mem limit = " << result << endl; + + // cpu time limit since occassionally the triangulator can go into + // and infinite loop. + limit.rlim_cur = 120; + limit.rlim_max = 120; + result = setrlimit( RLIMIT_CPU, &limit ); + cout << "result of setting mem limit = " << result << endl; + // main construction data management class FGConstruct c; diff --git a/Tools/Construct/Parallel/client.cxx b/Tools/Construct/Parallel/client.cxx index d4ca29e16..541947bfd 100644 --- a/Tools/Construct/Parallel/client.cxx +++ b/Tools/Construct/Parallel/client.cxx @@ -134,7 +134,10 @@ bool construct_tile( const string& work_base, const string& output_base, if ( line_str == "[Finished successfully]" ) { fclose(fp); return true; - } else if ( line_str == "Error: Ran out of precision at" ) { + } else if + ( (line_str.substr(0, 31) == "Error: Ran out of precision at") + || (line_str.substr(0, 22) == "Error: Out of memory.") + || (line_str.substr(0, 23) == "Error: Too many nodes.") ) { if ( angle > 9.0 ) { angle = 5.0; still_trying = true; @@ -143,8 +146,16 @@ bool construct_tile( const string& work_base, const string& output_base, still_trying = true; } } + } fclose(fp); + + if ( !still_trying && ( angle > 0.0 ) ) { + // build died for some reason ... lets try one last time + // with an interior angle restriction of 0 + angle = 0.0; + still_trying = true; + } } return false; } diff --git a/Tools/Construct/Parallel/server.cxx b/Tools/Construct/Parallel/server.cxx index 9ce5759cb..66cc9b394 100644 --- a/Tools/Construct/Parallel/server.cxx +++ b/Tools/Construct/Parallel/server.cxx @@ -133,11 +133,13 @@ long int get_next_tile( const string& work_base ) // reset lat // lat = -89.0 + (shift_up*dy) - (dy*0.5); + // lat = 27.0 + (0*dy) + (dy*0.5); lat = 15.0 + (shift_up*dy) + (dy*0.5); // reset lon FGBucket tmp( 0.0, lat ); double dx = tmp.get_width(); + // lon = -82 + (shift_over*dx) + (dx*0.5); lon = -180 + (shift_over*dx) + (dx*0.5); cout << "starting pass = " << pass