Crash: Overflow in memory allocator

Hi,

We’re currently having a problem with crashes in the build version because of A* (Pro Beta 4.3.58, Unity 2022.1.15). The problem occurs on multiple devices after a short time. We’re using a Grid Graph and the crash randomly occurs after calling astarPath.UpdateGraphs(bounds).

This is the relevant part from the crash log:

Overflow in memory allocator.
UnityEngine.StackTraceUtility:ExtractStackTrace ()
Unity.Collections.NativeArray`1<int>:Allocate (int,Unity.Collections.Allocator,Unity.Collections.NativeArray`1<int>&)
Unity.Collections.NativeArray`1<int>:.ctor (int,Unity.Collections.Allocator,Unity.Collections.NativeArrayOptions)
Pathfinding.Jobs.JobDependencyTracker:NewNativeArray<int> (int,Unity.Collections.Allocator,Unity.Collections.NativeArrayOptions) (at G:/Git/Project/Project/Library/PackageCache/com.arongranberg.astar@4.3.57/Utilities/JobDependencyTracker.cs:250)
Pathfinding.GridGraph/<UpdateAreaBurstCoroutine>d__107:MoveNext () (at G:/Git/Project/Project/Library/PackageCache/com.arongranberg.astar@4.3.57/Generators/GridGenerator.cs:1930)
Pathfinding.Jobs.JobHandleWithMainThreadWork:Complete () (at G:/Git/Project/Project/Library/PackageCache/com.arongranberg.astar@4.3.57/Utilities/JobDependencyTracker.cs:98)
Pathfinding.GridGraph:Pathfinding.IUpdatableGraph.UpdateArea (Pathfinding.GraphUpdateObject) (at G:/Git/Project/Project/Library/PackageCache/com.arongranberg.astar@4.3.57/Generators/GridGenerator.cs:3020)
Pathfinding.GraphUpdateProcessor:ProcessRegularUpdates (bool) (at G:/Git/Project/Project/Library/PackageCache/com.arongranberg.astar@4.3.57/Core/Misc/GraphUpdateProcessor.cs:277)
Pathfinding.GraphUpdateProcessor:ProcessGraphUpdates (Pathfinding.IWorkItemContext,bool) (at G:/Git/Project/Project/Library/PackageCache/com.arongranberg.astar@4.3.57/Core/Misc/GraphUpdateProcessor.cs:193)
Pathfinding.WorkItemProcessor:ProcessWorkItems (bool,bool) (at G:/Git/Project/Project/Library/PackageCache/com.arongranberg.astar@4.3.57/Core/Misc/WorkItemProcessor.cs:301)
Pathfinding.WorkItemProcessor:ProcessWorkItemsForUpdate (bool) (at G:/Git/Project/Project/Library/PackageCache/com.arongranberg.astar@4.3.57/Core/Misc/WorkItemProcessor.cs:381)
AstarPath:PerformBlockingActions (bool) (at G:/Git/Project/Project/Library/PackageCache/com.arongranberg.astar@4.3.57/Core/AstarPath.cs:884)
AstarPath:Update () (at G:/Git/Project/Project/Library/PackageCache/com.arongranberg.astar@4.3.57/Core/AstarPath.cs:867)

Do you have any idea what could be the reason for the crash? Thank you in advance.

Best regards

Niklas

Hi

I have not seen this before. Do you have a way to consistently replicate this?

Thank you for the fast reply! We found a situation where we can replicate it, but just in our project. It’s a tycoon game with a building system and everytime you build something the pathfinding is updated in this boundary.
The crash only seems to occur in the build version in one specific scene. If you start playing normally in this scene, it normally crashes in less than 5 minutes. To replicate it faster, we’ve built a lot of things as fast as possible, then it usually crashes in less than 1 minute.

Are there any additional logs or informations we can send you?

Okay.

Do you think you could send me the contents of the line it is pointing to?

Pathfinding.GridGraph/<UpdateAreaBurstCoroutine>d__107:MoveNext () (at G:/Git/Project/Project/Library/PackageCache/com.arongranberg.astar@4.3.57/Generators/GridGenerator.cs:1930)

Line numbers change so much between builds, it’s hard for me to track them down reliably.

Sure, the line is:

var nodeIndices = dependencyTracker.NewNativeArray(updateBounds.volume, context.data.allocationMethod, NativeArrayOptions.ClearMemory);

Thanks! Would you mind adding a Debug.Log(updateBounds + " " + updateBounds.volume) call right before that? And see what that logs. I have a feeling it might become negative, somehow.
You may have to copy the whole pathfinding package into your Assets folder to be able to edit it.

Alright, I’ll just try it out and send it to you in a minute.

No rush, it’s almost 2 AM for me. I’ll not have any more time to analyze it until at earliest tomorrow evening, possibly not until Monday.

No problem :slight_smile:
You were absolutely right! The volume is negative. This is the output from the Debug.Log:
(int3(4, 0, 4) <= x <= int3(3, 1, 12)) -8

Thanks! Found and fixed the bug. It will be included in the next update.

It happens only for graph updates that are almost, but not quite, inside a graph.

Thank you so much for this unbelievable fast fix! Definitely the best support I’ve seen for a long time, keep up the great work! :slight_smile:

1 Like

Hey, is there already an ETA for the next update? :slight_smile:
We are eagerly waiting for it so that we can make an update, because the crashes are affecting our game quite a bit at the moment.

It’s uploaded now :slight_smile:

1 Like

Thanks a lot! I’ve just tested it, the crash is gone :slight_smile:

1 Like