(5.0.3) Crash when using FleePath

Ok, here is another version :slight_smile:

The blue lines mark the Trace() calls…
In between you see when a unit calls the FleePath() method…

And here the two stacktraces for “389”

389 FleePath Trace
UnityEngine.Debug:Log (object)
Pathfinding.Path:Trace (uint) (at ./Library/PackageCache/com.arongranberg.astar@5.0.4/Core/Pathfinding/Path.cs:718)
Pathfinding.RandomPath:OnFoundEndNode (uint,uint,uint) (at ./Library/PackageCache/com.arongranberg.astar@5.0.4/Pathfinders/RandomPath.cs:197)
Pathfinding.RandomPath:OnVisitNode (uint,uint,uint) (at ./Library/PackageCache/com.arongranberg.astar@5.0.4/Pathfinders/RandomPath.cs:220)
Pathfinding.Path:CalculateStep (long) (at ./Library/PackageCache/com.arongranberg.astar@5.0.4/Core/Pathfinding/Path.cs:1018)
Pathfinding.Path:Pathfinding.IPathInternals.CalculateStep (long) (at ./Library/PackageCache/com.arongranberg.astar@5.0.4/Core/Pathfinding/Path.cs:1050)
Pathfinding.PathProcessor:CalculatePathsThreaded (Pathfinding.PathHandler,Pathfinding.BlockableChannel`1/Receiver<Pathfinding.Path>) (at ./Library/PackageCache/com.arongranberg.astar@5.0.4/Core/Pathfinding/PathProcessor.cs:329)
Pathfinding.PathProcessor/<>c__DisplayClass27_0:<StartThreads>b__0 () (at ./Library/PackageCache/com.arongranberg.astar@5.0.4/Core/Pathfinding/PathProcessor.cs:121)
System.Threading.ThreadHelper:ThreadStart ()
389 FleePath Trace
UnityEngine.Debug:Log (object)
Pathfinding.Path:Trace (uint) (at ./Library/PackageCache/com.arongranberg.astar@5.0.4/Core/Pathfinding/Path.cs:718)
Pathfinding.RandomPath:OnFoundEndNode (uint,uint,uint) (at ./Library/PackageCache/com.arongranberg.astar@5.0.4/Pathfinders/RandomPath.cs:197)
Pathfinding.RandomPath:OnVisitNode (uint,uint,uint) (at ./Library/PackageCache/com.arongranberg.astar@5.0.4/Pathfinders/RandomPath.cs:220)
Pathfinding.TriangleMeshNode:OpenAtPoint (Pathfinding.Path,uint,Pathfinding.Int3,int,uint) (at ./Library/PackageCache/com.arongranberg.astar@5.0.4/Graphs/Nodes/TriangleMeshNode.cs:388)
Pathfinding.TriangleMeshNode:Open (Pathfinding.Path,uint,uint) (at ./Library/PackageCache/com.arongranberg.astar@5.0.4/Graphs/Nodes/TriangleMeshNode.cs:339)
Pathfinding.Path:CalculateStep (long) (at ./Library/PackageCache/com.arongranberg.astar@5.0.4/Core/Pathfinding/Path.cs:1022)
Pathfinding.Path:Pathfinding.IPathInternals.CalculateStep (long) (at ./Library/PackageCache/com.arongranberg.astar@5.0.4/Core/Pathfinding/Path.cs:1050)
Pathfinding.PathProcessor:CalculatePathsThreaded (Pathfinding.PathHandler,Pathfinding.BlockableChannel`1/Receiver<Pathfinding.Path>) (at ./Library/PackageCache/com.arongranberg.astar@5.0.4/Core/Pathfinding/PathProcessor.cs:329)
Pathfinding.PathProcessor/<>c__DisplayClass27_0:<StartThreads>b__0 () (at ./Library/PackageCache/com.arongranberg.astar@5.0.4/Core/Pathfinding/PathProcessor.cs:121)
System.Threading.ThreadHelper:ThreadStart ()

This is very strange.

The RandomPath.OnVisitNode method checks

if (CompleteState == PathCompleteState.Complete) return;

but RandomPath.OnFoundEndNode sets

CompleteState = PathCompleteState.Complete;

right before it calls Trace. So it shouldn’t be possible to call it twice.

Would you mind setting A* Inspector → Settings → Threads = None (or One). To see if that changes anything.

Same result with “One” thread:

But after 3x tries, I would say that it doesn’t happen with “None” threads…

Btw, when switching to “None” or “One” thread, I always get about a dozen of "A Native Collection has not been disposed, resulting in a memory " when pressing play, and I have to restart the editor to make it work.

Should I try out with Version 5.0.5?

The changelog doesn’t mention any bugfixes…

I really don’t know what’s going on with your project.

Are you sure it’s not possible to share it with me so I can have a look?

Thanks!
I found the bug!

It only triggered when the path calculation was cancelled from the main thread, but the path calculation had just found a valid end point.
I’ll include a fix in the next update.

1 Like

Woohoo! Well done, looking forward to the fix :+1: :grin: :clap: