Staballocator exception

Hi,

I am using your latest version ie 5.1.1 but I have a very frequent issue (not consistent) with Slaballocator

public UnsafeSpan GetSpan (int allocatedIndex) seems to be called with a parameter allocatedIndex = -2 which causes the exception few line below :

if (allocatedIndex < sizeof(Header) || allocatedIndex >= data->mem.Length) throw new System.IndexOutOfRangeException($“Invalid allocation {allocatedIndex}”);

Here is the entire callstack :

IndexOutOfRangeException: Invalid allocation -2
Pathfinding.Util.SlabAllocator1[T].GetSpan (System.Int32 allocatedIndex) (at ./Library/PackageCache/com.arongranberg.astar@5.1.1/Core/Collections/SlabAllocator.cs:93) Pathfinding.HierarchicalGraph+JobRecalculateComponents.RemoveHierarchicalNode (Pathfinding.HierarchicalGraph hGraph, System.Int32 hierarchicalNode, System.Boolean removeAdjacentSmallNodes) (at ./Library/PackageCache/com.arongranberg.astar@5.1.1/Core/Pathfinding/HierarchicalGraph.cs:274) Pathfinding.HierarchicalGraph+JobRecalculateComponents.Execute () (at ./Library/PackageCache/com.arongranberg.astar@5.1.1/Core/Pathfinding/HierarchicalGraph.cs:474) Unity.Jobs.IJobExtensions+JobStruct1[T].Execute (T& data, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) (at :0)

I got another issue the same class when removing cuts from mesh but it does not seem consistent :

Exception: SlabAllocator cannot allocate more than 2^(MaxAllocationSizeIndex-1) elements
Pathfinding.Util.SlabAllocator1[T].ElementsToSizeIndex (System.Int32 nElements) (at ./Library/PackageCache/com.arongranberg.astar@5.1.1/Core/Collections/SlabAllocator.cs:151) Pathfinding.Util.SlabAllocator1[T].Realloc (System.Int32& allocatedIndex, System.Int32 nElements) (at ./Library/PackageCache/com.arongranberg.astar@5.1.1/Core/Collections/SlabAllocator.cs:129)
Pathfinding.Util.SlabAllocator1+List[T].Add (T value) (at ./Library/PackageCache/com.arongranberg.astar@5.1.1/Core/Collections/SlabAllocator.cs:283) Pathfinding.HierarchicalGraph+JobRecalculateComponents.FindHierarchicalNodeChildren (Pathfinding.HierarchicalGraph hGraph, System.Int32 hierarchicalNode, Pathfinding.GraphNode startNode) (at ./Library/PackageCache/com.arongranberg.astar@5.1.1/Core/Pathfinding/HierarchicalGraph.cs:421) Pathfinding.HierarchicalGraph+JobRecalculateComponents.Execute () (at ./Library/PackageCache/com.arongranberg.astar@5.1.1/Core/Pathfinding/HierarchicalGraph.cs:504) Unity.Jobs.IJobExtensions+JobStruct1[T].Execute (T& data, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) (at :0)

Any clue on these issues ?

Thank you in advance

3 Likes

I am also getting Staballocator exceptions today. I am not sure what I changed this morning that triggered this but now that I have it my scene is practically useless. I’m trying to enable things one element at a time to isolate what is causing this but my results are inconsistent and I can’t figure out what is causing this.

@MurphyII were you able to resolve this?

I am using 5.1.2 with a Layered Grid Graph.

Hi @bufothejig,
not yet but those are not consistent on my side. Let me know if you can locate the issue, but I am mixing navGraph & pointGraph so not sure if we could find a solution.

I am still waiting for feedbacks.

Best

Hi

If any of you could share an example project that would allow me to reproduce the issue, that would be amazing. I have not been able to replicate this locally.

I managed to make mine go away but it may have been related to a bug on my part.

My layered grid graph procedurally creates nodelink2 connections to handle jumping up/down.

I had a bug where I was never deleting created nodelink2 connections so I had thousands upon thousands of them in my scene.

Once I hit some threshold after procedurally creating connections I got the staballocator exceptions 100% of the time.

In my case, fixing the bug I had and deleting all of the nodelink2 connections I had created before making new ones led to only a few hundred in my scene and the staballocator exceptions went away.

Not sure if this is helpful or not but I at least found a way around it in my case. Good luck!

1 Like