Board index FlightGear Development Weather

Bug in Advanced Weather routines ?  Topic is solved

Everything related to weather simulation, visuals should be discussed in the shader subforum.

Bug in Advanced Weather routines ?

Postby V12 » Tue Nov 06, 2018 2:36 pm

On my transoceanic flights after METAR changes I observed many Nasal bugs like this one :
Nasal runtime error : Undefined symbol : cs
at /usr/share/games/flightgear/Nasal/local_weather/compat_layer.nas line 560

When I checked that code I found something like this :
Code: Select all
if (buffer_flag == 1)
   {
   var cs = weather_tile_management.cloudScenery.new(tile_counter, convective_flag, cl, model);
   append(weather_tile_management.cloudSceneryArray,cs);
   }

# if weather dynamics is on, also create a timestamp property and sort the cloud hash into quadtree

if (local_weather.dynamics_flag == 1)
   {
   cs.timestamp = weather_dynamics.time_lw;
   cs.write_index = placement_index;


   if (getprop(lw~"tmp/buffer-status") == "placing")
      {
      var blat = buffered_tile_latitude;
      var blon = buffered_tile_longitude;
      var alpha = buffered_tile_alpha;
      }
   else
      {
      var blat = getprop(lw~"tiles/tmp/latitude-deg");
      var blon = getprop(lw~"tiles/tmp/longitude-deg");
      var alpha = getprop(lw~"tmp/tile-orientation-deg");
      }
   weather_dynamics.sort_into_quadtree(blat, blon, alpha, lat, long, weather_dynamics.cloudQuadtrees[tile_counter-1], cs);
   }


Variable cs is defined only if buffer_flag=1, but when I monitoring this flag in property browser for local_weather/config/buffer_flag, I never see other value than zero. Result is clear - no clouds at the scene after runtime error. Can someone deeply analyze that error ?
I have solution - move var cs=.... before line with if (buffer_flag == 1), but I'm not sure with other consequences.

This bug is in 2018.2.1, 2018.2.2, 2018.3.0 and in 2018.4.0 too :(
Fly high, fly fast - fly Concorde !
User avatar
V12
 
Posts: 1563
Joined: Thu Jan 12, 2017 4:27 pm
Location: LZIB
Callsign: BAWV12

Re: Bug in Advanced Weather routines ?

Postby Thorsten » Tue Nov 06, 2018 3:10 pm

This looks like inside legacy code - so the relevant question is how the problem is triggered in the first place? I've done a number of tests in METAR mode and never seen it (and to my knowledge most people fly with METAR mode and I've not seen other reports either).
Thorsten
 
Posts: 11069
Joined: Mon Nov 02, 2009 8:33 am

Re: Bug in Advanced Weather routines ?

Postby wkitty42 » Tue Nov 06, 2018 3:52 pm

from the bit of code posted, it would appear that the buffer_flag should be on... the question is what setting(s) turns it on?
"You get more air close to the ground," said Angalo. "I read that in a book. You get lots of air low down, and not much when you go up."
"Why not?" said Gurder.
"Dunno. It's frightened of heights, I guess."
User avatar
wkitty42
 
Posts: 5695
Joined: Fri Feb 20, 2015 3:46 pm
Location: central NC, USA
Callsign: wk42
Version: git next
OS: Kubuntu 14.04.5

Re: Bug in Advanced Weather routines ?

Postby Thorsten » Tue Nov 06, 2018 4:07 pm

If you look into

https://sourceforge.net/p/flightgear/fg ... faults.xml

you find that it defaults to 1, there's no GUI option to change that any more, and the software flag is initialized to 1 in local_weather.nas

So the real question is - how did the OP manage to turn it off?
Thorsten
 
Posts: 11069
Joined: Mon Nov 02, 2009 8:33 am

Re: Bug in Advanced Weather routines ?

Postby V12 » Tue Nov 06, 2018 4:34 pm

5 minutes ago I found another bug vector index -1 out of bound in the file weather_tile_management.nas at line 1488 :

var s = cloudShadowArray[index_min];

But index_min is initiated with value -1 and when in the scene doesn't exist any cloud with shadow, value is always zero. This bug has been initiated with manual weather type from Fair weather to Stormy monday.

Solution should be simple - new condition
Code: Select all
if (index_min>0)
{
   var s = cloudShadowArray[index_min];
   
   diffx = (s.lat - eyeLat) * local_weather.lat_to_m + offset_x;
   diffy = -(s.lon - eyeLon) * local_weather.lon_to_m + offset_y;
   
   setprop("/local-weather/cloud-shadows/nearest-cloudpos-x",int(diffx) + s.size);
   setprop("/local-weather/cloud-shadows/nearest-cloudpos-y",int(diffy) + s.strength );
   
   #print("Dist_max:", dist_max, " index_max: ", index_max);
   cloudShadowMinIndex = index_max;
   if (dist_max > 0.0) {cloudShadowMaxDist = dist_max;}   
};


Probably, there is possibility of the another problem :

Code: Select all
###########################################################
# remove unused echos
###########################################################

var remove_wxradar_echos = func {

var distance_to_remove = 70000.0;

var storms = props.globals.getNode("/instrumentation/wxradar", 1).getChildren("storm");

var pos = geo.aircraft_position();

foreach (s; storms)
   {
   var d_sq = local_weather.calc_d_sq(pos.lat(), pos.lon(), s.getNode("latitude-deg").getValue(), s.getNode("longitude-deg").getValue());
   if (d_sq > distance_to_remove * distance_to_remove)
      {
      s.remove();
      }
   }

}

There is not any tests for non zero in the variable storms.
Fly high, fly fast - fly Concorde !
User avatar
V12
 
Posts: 1563
Joined: Thu Jan 12, 2017 4:27 pm
Location: LZIB
Callsign: BAWV12

Re: Bug in Advanced Weather routines ?

Postby Thorsten » Tue Nov 06, 2018 6:14 pm

5 minutes ago I found another bug vector index -1 out of bound in the file weather_tile_management.nas at line 1488


I'm not really interested in assembling a pile of reports now, I'm interested in

So the real question is - how did the OP manage to turn it off?
Thorsten
 
Posts: 11069
Joined: Mon Nov 02, 2009 8:33 am

Re: Bug in Advanced Weather routines ?

Postby V12 » Tue Nov 06, 2018 8:25 pm

I manualy changed local_weather/config/buffer-flag from false to true, restarted FG and this property was true. Why was false, I don't know.
Then checked second PC with fresh installed Lubuntu 18.10 and FG 2018.2.2, property was true after FG started. On third PC I found same behaviour - property was allways true.

Is there any reason to some aircraft should modify that property ? I tested many aircrafts from many sources other than fgaddon.
Fly high, fly fast - fly Concorde !
User avatar
V12
 
Posts: 1563
Joined: Thu Jan 12, 2017 4:27 pm
Location: LZIB
Callsign: BAWV12

Re: Bug in Advanced Weather routines ?

Postby legoboyvdlp » Tue Nov 06, 2018 10:05 pm

Perhaps you could use a tool such as grep in your aircraft folders for 'buffer-flag'?

That will pick up any aircraft that modify it (whether in -set, jsb, or nasal)?
User avatar
legoboyvdlp
 
Posts: 7088
Joined: Sat Jul 26, 2014 1:28 am
Callsign: YV-LEGO
Version: 2018.3.1
OS: Windows 10 HP

Re: Bug in Advanced Weather routines ?  

Postby V12 » Wed Nov 07, 2018 5:28 am

Checked, Now, I have not any aircraft that try modify buffer-flag property. I deleted all autosave files, all aircraft's config files and after this :
V12 wrote in Tue Nov 06, 2018 8:25 pm:I manualy changed local_weather/config/buffer-flag from false to true

the error "Undefined symbol : cs " was not repeated again under any circumstances. Problem "vector index -1 out of bound in the file weather_tile_management.nas at line 1488" solved as described in viewtopic.php?p=338439#p338439.
Fly high, fly fast - fly Concorde !
User avatar
V12
 
Posts: 1563
Joined: Thu Jan 12, 2017 4:27 pm
Location: LZIB
Callsign: BAWV12

Re: Bug in Advanced Weather routines ?

Postby Thorsten » Wed Nov 07, 2018 6:57 am

Is there any reason to some aircraft should modify that property ? I tested many aircrafts from many sources other than fgaddon.


There's really only two possibilities to set this: Manually with the property browser (I suppose since the flag is a boolean it could potentially be clicked by mistake by a super-user who delves into AW inner workings) - but it seems hard to do this without being aware that manual modifications are being done to the AW state.

Or via a setprop. The only pieces of code that should legitimately write into the AW property tree are the AW subroutines and the AW GUI - nothing else inside FG should write there. The GUI option is, as I said, disabled (and has been for many years), and AW Nasal does not write this.

A malicious aircraft on the other hand (for whatever reason) could set this - the huge configurability FG offers unfortunately means that simply using an aircraft can wreck the configuration of your existing FG install for good. FG is protected to the degree that such operations are fairly restricted and simply wiping your user-side config files should take care of things - but it is a possible scenario that someone with insight into FGs workings offers an aircraft that intentionally (or by mistake) causes such problems - you just need to run the aircraft once and then delete it in this case and your config would already be faulty.

But index_min is initiated with value -1 and when in the scene doesn't exist any cloud with shadow, value is always zero. This bug has been initiated with manual weather type from Fair weather to Stormy monday.


I'm unable to reproduce this - for me changing from Fair weather to Stormy Monday works fine. So I need a recipe to reproduce this, not hacks to conditions.
Thorsten
 
Posts: 11069
Joined: Mon Nov 02, 2009 8:33 am

Re: Bug in Advanced Weather routines ?

Postby V12 » Thu Jan 17, 2019 5:59 pm

I found repeatable error in AW - check this screenshot :

Image

I deleted my config file, tested on vanilla install, bug reappears almost on all flights, when METAR reports few or scattered clouds.
Fly high, fly fast - fly Concorde !
User avatar
V12
 
Posts: 1563
Joined: Thu Jan 12, 2017 4:27 pm
Location: LZIB
Callsign: BAWV12

Re: Bug in Advanced Weather routines ?

Postby legoboyvdlp » Thu Jan 17, 2019 6:04 pm

Grad is set:

Code: Select all
if (detailed_terrain_interaction_flag == 1)
            {
            var grad = get_terrain_gradient(lat, lon, elevation, alpha, 1000.0);
            }
         else
            {var grad = 0.0;}


not sure how this occur?

Can you show the AW settings?
User avatar
legoboyvdlp
 
Posts: 7088
Joined: Sat Jul 26, 2014 1:28 am
Callsign: YV-LEGO
Version: 2018.3.1
OS: Windows 10 HP

Re: Bug in Advanced Weather routines ?

Postby V12 » Fri Jan 18, 2019 5:54 am

Image
Fly high, fly fast - fly Concorde !
User avatar
V12
 
Posts: 1563
Joined: Thu Jan 12, 2017 4:27 pm
Location: LZIB
Callsign: BAWV12

Re: Bug in Advanced Weather routines ?

Postby V12 » Fri Jan 18, 2019 6:46 am

Early morning programmer's warm-up :
variable grad is defined localy in the procedure create_cumulus, but error occured in the other procedure recreate_cumulus where grad is not defined...
Fly high, fly fast - fly Concorde !
User avatar
V12
 
Posts: 1563
Joined: Thu Jan 12, 2017 4:27 pm
Location: LZIB
Callsign: BAWV12

Re: Bug in Advanced Weather routines ?

Postby Thorsten » Fri Jan 18, 2019 7:21 am

variable grad is defined localy in the procedure create_cumulus, but error occured in the other procedure recreate_cumulus where grad is not defined...


Early morning programmers warmup - this doesn't matter because the routine in question is an experimental, six-year old code path which is disabled by default and can't be enabled in the GUI - you have to manually edit a config file or use the property browser to activate it, and if you opt to do so, it's kind of your own problem to deal with the consequences.

Please do not do super-user type things with the AW config and report them as bugs.
Thorsten
 
Posts: 11069
Joined: Mon Nov 02, 2009 8:33 am

Next

Return to Weather

Who is online

Users browsing this forum: Applebot [Bot] and 0 guests

cron