View Issue Details

IDProjectCategoryLast Update
0026161AI War 2Crash/ExceptionJan 24, 2022 1:05 pm
ReporterBadgerBadger Assigned ToChris_McElligottPark  
Severityminor 
Status resolvedResolutionfixed 
Product VersionBeta 3.785 Just Bugfixes 
Fixed in VersionBeta 3.786 A Very Intense Patch 
Summary0026161: Excpetion in stringbuilder
Description1/24/2022 10:26:06 AM 3.785 SINGLEP DELAYED927 TID47 Exception in ZA stage 2, debugCode 2300 System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: chunkLength
  at System.Text.StringBuilder.ToString () [0x000a6] in <695d1cc93cca45069c528c15c9fdd749>:0
  at Arcen.Universal.ArcenDoubleCharacterBuffer.GetStringAndResetForNextUpdate () [0x0008b] in /data/Games/arcengames_aiw-ultra/CodeCrossProject/ArcenUniversal/src/ArcenBuffers/ArcenDoubleCharacterBuffer.cs:317
  at Arcen.AIW2.External.ZenithArchitraveFactionBaseInfo+<DoPerSecondLogic_Stage2Aggregating_OnMainThreadAndPartOfSim_ClientAndHost>c__AnonStorey1.<>m__0 (Arcen.AIW2.Core.GameEntity_Squad entity) [0x002a4] in <06182f5b615443f7ad7390daccc003a8>:0
  at Arcen.AIW2.Core.EntityCollection.DoForEntities (Arcen.AIW2.Core.GameEntity_Squad+ProcessorDelegate Processor) [0x0004d] in /data/Games/arcengames_aiw-ultra/CodeMain/ArcenAIW2Core/src/Logic/GameState/GameEntity/EntityCollection.cs:815
  at Arcen.AIW2.Core.Faction.DoForEntities_DebugOnly (Arcen.AIW2.Core.GameEntity_Squad+ProcessorDelegate Processor) [0x00036] in /data/Games/arcengames_aiw-ultra/CodeMain/ArcenAIW2Core/src/Logic/GameState/Faction/Faction.cs:2794
  at Arcen.AIW2.External.ZenithArchitraveFactionBaseInfo.DoPerSecondLogic_Stage2Aggregating_OnMainThreadAndPartOfSim_ClientAndHost (Arcen.AIW2.Core.ArcenClientOrHostSimContextCore Context) [0x000b1] in <06182f5b615443f7ad7390daccc003a8>:0

I believe this is from the code
                        foreach ( KeyValuePair<GameEntityTypeData, int> kv in data.ShipsInside )
                        {
                            debugCode = 2200;
                            GameEntityTypeData.MarkLevelStats markLevelStats = kv.Key.MarkStatsFor( data.MarkLevelForShips );
                            strengthForUnit += (markLevelStats.StrengthPerSquad_CalculatedWithNullFleetMembership * kv.Value);
                            if ( kv.Value > 0 )
                                Buffer_ForShipsInside.Add( kv.Key.GetDisplayName(), "909090" ).Add( " x" + kv.Value.ToString(), markByOrdinal.ColorHex ).Add( ", " );
                        }
                        debugCode = 2300;
                        strength += strengthForUnit;
                        Buffer_ForShipsInside.Add( " with total strength " ).Add( ((strengthForUnit) / 1000).ToString(), "a1ffa1" ).Add( ".\n" );
                        data.ShipsInside_ForUI = Buffer_ForShipsInside.GetStringAndResetForNextUpdate();

I hit this with the save game from 0026133
TagsNo tags attached.

Relationships

related to 0026133 resolvedBadgerBadger faction fatal error 

Activities

Chris_McElligottPark

Jan 24, 2022 12:42 pm

administrator   ~0063851

Anytime there is an error in stringbuilder, that means one thing: it's being written to from multiple threads at once.

Chris_McElligottPark

Jan 24, 2022 1:05 pm

administrator   ~0063855

Found it. Thanks!

* Discovered that there were a couple of places where parts of the Stage 1 or Stage 2 faction logic could be run on multiple threads at once if one of them took a long time and you were switching between a paused and unpaused state.
** This is something that made for some very nonsensical errors, as well as slowing the game down a lot when it happened. All fixed now, should be.

Issue History

Date Modified Username Field Change
Jan 24, 2022 12:29 pm BadgerBadger New Issue
Jan 24, 2022 12:29 pm BadgerBadger Status new => assigned
Jan 24, 2022 12:29 pm BadgerBadger Assigned To => Chris_McElligottPark
Jan 24, 2022 12:42 pm Chris_McElligottPark Note Added: 0063851
Jan 24, 2022 12:42 pm Chris_McElligottPark Relationship added related to 0026133
Jan 24, 2022 1:05 pm Chris_McElligottPark Status assigned => resolved
Jan 24, 2022 1:05 pm Chris_McElligottPark Resolution open => fixed
Jan 24, 2022 1:05 pm Chris_McElligottPark Fixed in Version => Beta 3.786 A Very Intense Patch
Jan 24, 2022 1:05 pm Chris_McElligottPark Note Added: 0063855