IndexOutOfRangeException: Invalid allocation -2

After i updated to 5.3.3 i can’t get rid of the following error:

IndexOutOfRangeException: Invalid allocation -2
Pathfinding.Collections.SlabAllocator`1[T].GetSpan (System.Int32 allocatedIndex) (at ./Packages/com.arongranberg.astar/Core/Collections/SlabAllocator.cs:112)
Pathfinding.NavmeshEdges+NavmeshBorderData.GetHierarchicalNodesInRangeRec (System.Int32 hierarchicalNode, UnityEngine.Bounds bounds, Pathfinding.Collections.SlabAllocator`1[T] connectionAllocator, Unity.Collections.NativeList`1[T] connectionAllocations, Unity.Collections.NativeList`1[T] nodeBounds, Unity.Collections.NativeList`1[T] indices) (at ./Packages/com.arongranberg.astar/Core/Misc/NavmeshEdges.cs:305)
Pathfinding.NavmeshEdges+NavmeshBorderData.GetObstaclesInRange (System.Int32 hierarchicalNode, UnityEngine.Bounds bounds, Unity.Collections.NativeList`1[T] obstacleIndexBuffer) (at ./Packages/com.arongranberg.astar/Core/Misc/NavmeshEdges.cs:370)
Pathfinding.NavmeshEdges+NavmeshBorderData.GetEdgesInRange (System.Int32 hierarchicalNode, UnityEngine.Bounds localBounds, Unity.Collections.NativeList`1[T] edgeBuffer, Unity.Collections.NativeList`1[T] scratchBuffer, Pathfinding.Util.NativeMovementPlane movementPlane) (at ./Packages/com.arongranberg.astar/Core/Misc/NavmeshEdges.cs:376)
Pathfinding.ECS.JobControl.Execute (Unity.Transforms.LocalTransform& transform, Pathfinding.ECS.MovementState& state, Pathfinding.ECS.DestinationPoint& destination, Pathfinding.ECS.AgentCylinderShape& shape, Pathfinding.ECS.AgentMovementPlane& movementPlane, Pathfinding.ECS.MovementSettings& settings, Pathfinding.ECS.ResolvedMovement& resolvedMovement, Pathfinding.ECS.MovementControl& controlOutput) (at ./Packages/com.arongranberg.astar/Core/ECS/Jobs/JobControl.cs:65)
Pathfinding.ECS.JobControl.Execute (Unity.Entities.ArchetypeChunk& chunk, System.Int32 chunkIndexInQuery, System.Boolean useEnabledMask, Unity.Burst.Intrinsics.v128& chunkEnabledMask) (at ./JobEntityGenerator/Unity.Entities.SourceGen.JobEntityGenerator.JobEntityGenerator/Temp/GeneratedCode/AstarPathfindingProject/JobControl__JobEntity_135049637813.g.cs:47)
Pathfinding.ECS.JobControl.Unity.Entities.IJobChunk.Execute (Unity.Entities.ArchetypeChunk& chunk, System.Int32 unfilteredChunkIndex, System.Boolean useEnabledMask, Unity.Burst.Intrinsics.v128& chunkEnabledMask) <0x21cde1cb840 + 0x00072> in <d2f4ee5daf664d398bc98c7437dde790>:0
Unity.Entities.JobChunkExtensions+JobChunkProducer`1[T].ExecuteInternal (Unity.Entities.JobChunkExtensions+JobChunkWrapper`1[T]& jobWrapper, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) (at ./Library/PackageCache/com.unity.entities@1.3.8/Unity.Entities/IJobChunk.cs:420)
Unity.Entities.JobChunkExtensions+JobChunkProducer`1[T].Execute (Unity.Entities.JobChunkExtensions+JobChunkWrapper`1[T]& jobWrapper, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) (at ./Library/PackageCache/com.unity.entities@1.3.8/Unity.Entities/IJobChunk.cs:363)

Unity 2022.3.58 , Entities 1.3.8
I deleted the old plugin first and then imported the latest version.

When are you seeing this error, looks like it’s during runtime when an agent is moving?

Hi

Are you able to reliably replicate the issue?
If so, I would be very interested if you would want to share a test project where I could replicate it.

I downgraded for now. But i’ll try again during the next days.

I was able to solve the problem. Since I’m using a Baker and System and not FollowerEntity, I don’t know if the result will be useful to anyone else.

The reason was that the latest version was running FollowerControlSystem before my system added the ‘ManagedState’ component.
I add the ‘SimulateMovement’ component now in the System instead of Baker.

The change is also available here: