View Issue Details

IDProjectCategoryLast Update
0024484AI War 2Crash/ExceptionMar 2, 2021 11:13 am
ReporterSigma7 Assigned ToChris_McElligottPark  
Status resolvedResolutionfixed 
Product VersionBeta 2.746 Release The Warden 
Fixed in VersionBeta 2.750 Bastions And Tuning 
Summary0024484: NRE in BuildShipsLookup
DescriptionA campaign is throwing an exception based on some long range planning by the AI Warden fleet.

2/24/2021 8:08:02 PM 2.746 SINGLEP Start load save: G:/Games/SteamLibrary/steamapps/common/AI War 2/PlayerData/Save/Backdoor/bd 2021 02 18 3.save Source1: AnythingElse Source3: LoadingSaveGame
2/24/2021 8:08:03 PM 2.746 SINGLEP Recalculated Strengths For Loaded Galaxy Map in 21ms
2/24/2021 8:08:03 PM 2.746 SINGLEP Finish load save in 914.0ms
2/24/2021 8:37:19 PM 2.746 SINGLEP Reconquest Seeding for Das: guard post placer: EightSpreadOutGuardPosts scheduled: 8 actually seeded: 8
2/24/2021 8:42:03 PM 2.746 SINGLEP Reconquest Seeding for Crestholm: guard post placer: FourSpreadOutGuardPosts scheduled: 4 actually seeded: 4
2/24/2021 9:06:11 PM 2.746 SINGLEP Hit exception in BuildShipsLookup debugCode 410 exception System.NullReferenceException: Object reference not set to an instance of an object
  at Arcen.AIW2.External.Fireteam.BuildShipsLookup (System.Boolean includeShipsInTransit, Arcen.AIW2.Core.Planet destinationOrNull) [0x00168] in <8c9e2c0a1a7a422b9c459f79fe448814>:0
2/24/2021 9:06:11 PM 2.746 SINGLEP Unknown Exception in DoLongRangePlanning_OnBackgroundNonSimThread for faction AI Warden Fleet(Index 2), so will not run any more of those until a reload of the save. Check error log to see prior recorded exception.

The attached saves, "bd nre.save" and "bd fatal.save" were made after the exception popped up. The autosave should be before the exception, but I'm unsure on how to reproduce it from the autosave.
TagsNo tags attached.

Activities

Sigma7

Feb 24, 2021 9:15 pm

reporter  

Backdoor - nre warden.zip (1,848,344 bytes)

BadgerBadger

Feb 24, 2021 10:36 pm

manager   ~0060648

Suspected race condition between LRP and sim code, where the ship is being removed:

                for ( int i = 0; i < this.ships.Count; i++ )
                {
                    debugCode = 100;
                    GameEntity_Squad entity = this.ships[i];
                    if ( entity == null || entity.Planet == null )
                        continue;
....
                    debugCode = 410;
                    shipsByPlanet[entity.Planet].Add(entity);
                }
            }
.....
            catch (Exception e)

It looks like we are hitting a NRE when checking entity.Planet.

My first thought would be to cache the Planet at the beginning of the loop

Chris_McElligottPark

Mar 2, 2021 11:13 am

administrator   ~0060683

Thanks! Handled this a slightly different way, but we can adjust if needed based on future testing:

* Fireteams now use ConcurrentDictionary instead of ArcenSparseLookup, as apparently these could get a bit wires-crossed with multiple threads, and this may be slightly more efficient in general, anyway.
** This prevents certain nullref exceptions that could happen in BuildShipsLookup, and probably also a few other things.
** It's worth noting that it turns out that the foreach statement with a ConcurrentDictionary is fully thread-safe, and in general supports continuing iteration over the directionary while things are added or removed, which is a strange and wonderful superpower of this.

* Fixed a bug with some fireteam tracing always being on, and slow things down because of that, because of a tracing flag having a typo causing it not to be used. This may have only affected the scourge, not sure.

Issue History

Date Modified Username Field Change
Feb 24, 2021 9:15 pm Sigma7 New Issue
Feb 24, 2021 9:15 pm Sigma7 File Added: Backdoor - nre warden.zip
Feb 24, 2021 10:36 pm BadgerBadger Note Added: 0060648
Feb 24, 2021 11:40 pm Sigma7 Summary NRE in BuildShipsLoopup => NRE in BuildShipsLookup
Feb 24, 2021 11:40 pm Sigma7 Description Updated
Mar 2, 2021 11:13 am Chris_McElligottPark Assigned To => Chris_McElligottPark
Mar 2, 2021 11:13 am Chris_McElligottPark Status new => resolved
Mar 2, 2021 11:13 am Chris_McElligottPark Resolution open => fixed
Mar 2, 2021 11:13 am Chris_McElligottPark Fixed in Version => Beta 2.750 Bastions And Tuning
Mar 2, 2021 11:13 am Chris_McElligottPark Note Added: 0060683