On Sun, 2011-05-29 at 11:45 +0200, Christian Schmitt wrote:
> Geoff McLane wrote:
> > It certainly works better for me ;=)) And removes
> > another reason why fgfs-construct can abort
> > without apparent reason!
> 
> Hi,
> 
> you mean segfaults with no apparent reason? I experience them under Linux 
> when building huge scenery chunks and if your patch improves the situation, 
> I'll gladly give it a try.
> 
> Chris
> 

Hi Chris,

Exactly ;=))

I am not sure if it is the WHOLE reason, but 
under WIN32, where you get a 'small' indication 
of where the problem occurred, even on the release 
version - ie no debug symbols available - this is 
certainly one, perhaps _NOT_ the only ;=((, where 
a segfault can occur...

This part of the 'genfans' library is _NOT_ run on 
every bucket being built... so MANY buckets can 
be ok... ie no segfault... only in certain 
situations...

If you do your own 'exe' build, please give the 
patch a try... and advise if the situation 
improves...

This would certainly help the 'maintainers' of 
terragear cs to decide to incorporate the 
patch... although, at the moment, it seems 
very obvious to me...

Added to that... I have found another 
'no-apparent-reason' segfault can be caused 
by -

Re: src/BuildTiles/Clipper/priorities.cxx

ANOTHER patch I am working on for fgfs-contruct, 
and currently testing, is the building of the 
'area_types' array...

This is built from the reading of the 
'default_priorities.txt' file, or such other 
file as you designate via the '--priorities=<file>' 
specific command...

The reading of this file creates the 'area_types' 
array, which, no matter what, _MUST_ have at least 
'TG_MAX_AREA_TYPES' members (= 128 in the current 
build) ... 

There are a number of functions, here and there, 
having no 'knowledge' of the size of the 'area_types'
array, which use something like :-

 for (i = 0; i < TG_MAX_AREA_TYPES; i++) {
    area_type_descriptor type = get_area_descriptor(i);
    ...

BUT the static function -
 get_area_descriptor(AreaType area) -

(a) has a crazy, bad, stupid, range checking of -
    if ( 0<=area || area < area_types.size() ) {
This _MUST_ be something more like :-
    if ( area >= 0 && area < area_types.size() ) {

(b) thus the array may not be less than 
TG_MAX_AREA_TYPES in size()...
    if ( area >= 0 && area < area_types.size() ) {
        return area_types[area];
    } else {
       SG_LOG(SG_GENERAL, SG_ALERT, "unknown area code = " <<
(int)area);
       exit(-1);
    }

With the current range checking of -
    if ( 0<=area || area < area_types.size() ) {
this again means you can have a segfault when 
'area' is above the area_types.size() ;=((

My quick patch for this is attached, but it presently
depends on the _LAST_ entry in 'default_priorities.txt',
or such other designated file, having a FINAL entry 
of 

Unknown other

to fill the array out to 128 with 'Unknown', of 
priority value 7...

With these patches in place, I no longer get 
'strange' aborts from fgfs-construct ;=)) but 
welcome others testing, and reporting...

Regards,
Geoff.

attached: priorities-01.patch


--- C:\FGCVS\terragear-cs\src\BuildTiles\Clipper\priorities.cxx	Sun Oct 10 10:12:53 2010
+++ C:\FG\TG2\terragear-cs\src\BuildTiles\Clipper\priorities.cxx	Fri May 27 18:15:47 2011
@@ -31,6 +31,11 @@
 
 #include "priorities.hxx"
 
+#ifndef TG_MAX_AREA_TYPES
+#define TG_MAX_AREA_TYPES 128	// FIXME also defined in
+                                // MergerClipper/clipper.hxx
+#endif // TG_MAX_AREA_TYPES
+
 using std::ifstream;
 using std::string;
 using std::map;
@@ -75,8 +80,9 @@
     in >> skipcomment;
     in >> sliver_area_name;
     in >> skipcomment;
+    area_type_descriptor descriptor;
     while ( !in.eof() ) {
-        area_type_descriptor descriptor;
+        //area_type_descriptor descriptor;
         string type;
         descriptor.kind = Other;
         in >> descriptor.name;
@@ -109,6 +115,18 @@
     
     sliver_target_area_type = get_area_type( sliver_area_name );
     default_area_type = get_area_type( default_area_name );
+
+    if (area_types.size() < TG_MAX_AREA_TYPES) {
+        SG_LOG(SG_GENERAL, SG_INFO, "EEK: Area type count = " << area_types.size() <<
+            " being less that MAX = " << TG_MAX_AREA_TYPES << " UGH!" );
+        while (area_types.size() < TG_MAX_AREA_TYPES) {
+            AreaType index = (AreaType)area_types.size();
+            area_types.push_back(descriptor);
+            area_names[descriptor.name]=index;
+            SG_LOG(SG_GENERAL, SG_INFO, "  " << descriptor.name << " " << descriptor.kind);
+        }
+        return 2;
+    }
     
     return 1;
 }
@@ -125,12 +143,15 @@
 }
 
 
+//    if ( 0<=area || area < area_types.size() ) {
+// the above should be AND nor OR ;=((
 static area_type_descriptor& get_area_descriptor( AreaType area ) {
-    if ( 0<=area || area < area_types.size() ) {
+    if (( area >= 0 ) && ( area < area_types.size() )) {
         return area_types[area];
     } else {
 	SG_LOG(SG_GENERAL, SG_ALERT, "unknown area code = " << (int)area);
 	exit(-1);
+    // return area_types[default_area_type];
     }
 }
 
------------------------------------------------------------------------------
vRanger cuts backup time in half-while increasing security.
With the market-leading solution for virtual backup and recovery, 
you get blazing-fast, flexible, and affordable data protection.
Download your free trial now. 
http://p.sf.net/sfu/quest-d2dcopy1
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to