Unity crash in 5.0.2 when AiBase calls Physics.SyncTransforms()

I’m trying to diagnose an error that’s causing Unity crash on my machine quite consistently during hot reloading.

I’m not entirely sure what is the cause, but looking at the crash log from Unity I found that this happens during Pathfinding.AIBase.OnUpdate as it calls Physics.SyncTransforms

I only started experiencing this a few days ago, which is around the time I upgraded from 4.x to 5.x. Now this is also around the time I changed a few other things in the project, so I’m not entirely sure if this is the cause, but still thought I’d ask in case someone else has any ideas?

Here’s the stacktrace

Managed Stacktrace:

at <unknown> <0xffffffff>
at UnityEngine.Physics:SyncTransforms <0x00086>
at Pathfinding.AIBase:OnUpdate <0x00dca>
at System.Action`4:invoke_void_T1_T2_T3_T4 <0x00115>
at <>c__DisplayClass17_0`1:<Add>b__0 <0x0009d>
at Pathfinding.Util.BatchedEvents:Process <0x00155>
at Pathfinding.Util.BatchedEvents:Update <0x00022>
at System.Object:runtime_invoke_void__this__ <0x00087>

=================================================================

edit: I’m using Unity 2022.3.20f1 if that’s relevant.

edit: I’m using Unity 2022.3.20f1 if that’s relevant.

If I’m not mistaken, min required version of Unity for using version 5 of Pathfinding is 2022.3.21, so you can try to update your Unity version and check if this issue is still there.

Hi

If it crashes in that method, then it’s a Unity bug. I’d report it to Unity, but I first recommend to try upgrading your unity version.

I tried updating A* to 5.0.3 and Unity to 2022.3.21 but still getting a crash, though this time the managed stacktrace is different, but still happens during physics

Managed Stacktrace:

at <unknown> <0xffffffff>
at UnityEngine.CharacterController:Move_Injected <0x0009b>
at UnityEngine.CharacterController:Move <0x00022>
at Pathfinding.AIBase:FinalizePosition <0x00412>
at Pathfinding.AIBase:FinalizeMovement <0x00082>
at Pathfinding.AIBase:OnUpdate <0x0040f>
at Pathfinding.AIBase:OnUpdate <0x00c65>
at System.Action`4:invoke_void_T1_T2_T3_T4 <0x00115>
at <>c__DisplayClass17_0`1:<Add>b__0 <0x0009d>
at Pathfinding.Util.BatchedEvents:Process <0x00155>
at Pathfinding.Util.BatchedEvents:Update <0x00022>
at System.Object:runtime_invoke_void__this__ <0x00087>

=================================================================
Received signal SIGSEGV
Obtained 43 stack frames
0x00007ff7a5530503 (Unity) physx::Gu::AABBTreeOverlapphysx::Gu::AABBAABBTest,physx::Sq::AABBTree,physx::Sq::AABBTreeRuntimeNode,physx::Sq::PrunerPayload,physx::Sq::PrunerCallback::operator()
0x00007ff7a5539dff (Unity) physx::Sq::AABBPruner::overlap
0x00007ff7a553ef93 (Unity) physx::NpSceneQueries::multiQueryphysx::PxOverlapHit
0x00007ff7a5554b54 (Unity) physx::NpSceneQueries::overlap
0x00007ff7a548464f (Unity) physx::Cct::findTouchedGeometry
0x00007ff7a548db6c (Unity) physx::Cct::SweepTest::updateTouchedGeoms
0x00007ff7a54877d3 (Unity) physx::Cct::SweepTest::moveCharacter
0x00007ff7a54871c5 (Unity) physx::Cct::Controller::move
0x00007ff7a548640c (Unity) physx::Cct::CapsuleController::move
0x00007ff7a33be001 (Unity) CharacterController::Move
0x00007ff7a27540e6 (Unity) CharacterController_CUSTOM_Move_Injected
0x000001e4703c131c (Mono JIT Code) (wrapper managed-to-native) UnityEngine.CharacterController:Move_Injected (UnityEngine.CharacterController,UnityEngine.Vector3&)
0x000001e4703c1233 (Mono JIT Code) UnityEngine.CharacterController:Move (UnityEngine.Vector3)
0x000001e4703c0ba3 (Mono JIT Code) Pathfinding.AIBase:FinalizePosition (UnityEngine.Vector3) (at ./Library/PackageCache/com.arongranberg.astar@5.0.3/Core/AI/AIBase.cs:784)
0x000001e4703bec33 (Mono JIT Code) Pathfinding.AIBase:FinalizeMovement (UnityEngine.Vector3,UnityEngine.Quaternion) (at ./Library/PackageCache/com.arongranberg.astar@5.0.3/Core/AI/AIBase.cs:761)
0x000001e4703af1b0 (Mono JIT Code) Pathfinding.AIBase:OnUpdate (single) (at ./Library/PackageCache/com.arongranberg.astar@5.0.3/Core/AI/AIBase.cs:509)
0x000001e4703ac296 (Mono JIT Code) Pathfinding.AIBase:OnUpdate (Pathfinding.AIBase[],int,UnityEngine.Jobs.TransformAccessArray,Pathfinding.Util.BatchedEvents/Event) (at ./Library/PackageCache/com.arongranberg.astar@5.0.3/Core/AI/AIBase.cs:485)
0x000001e4703ac746 (Mono JIT Code) (wrapper delegate-invoke) System.Action4<Pathfinding.AIBase[], int, UnityEngine.Jobs.TransformAccessArray, Pathfinding.Util.BatchedEvents/Event>:invoke_void_T1_T2_T3_T4 (Pathfinding.AIBase[],int,UnityEngine.Jobs.TransformAccessArray,Pathfinding.Util.BatchedEvents/Event) 0x000001e4703ab60e (Mono JIT Code) Pathfinding.Util.BatchedEvents/<>c__DisplayClass17_01<T_REF>:b__0 (object[],int,UnityEngine.Jobs.TransformAccessArray,Pathfinding.Util.BatchedEvents/Event) (at ./Library/PackageCache/com.arongranberg.astar@5.0.3/Utilities/BatchedEvents.cs:192)
0x000001e470350156 (Mono JIT Code) Pathfinding.Util.BatchedEvents:Process (Pathfinding.Util.BatchedEvents/Event,System.Type) (at ./Library/PackageCache/com.arongranberg.astar@5.0.3/Utilities/BatchedEvents.cs:215)
0x000001e4703ab553 (Mono JIT Code) Pathfinding.Util.BatchedEvents:Update () (at ./Library/PackageCache/com.arongranberg.astar@5.0.3/Utilities/BatchedEvents.cs:232)
0x000001e1412e9898 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr)
0x00007ff8922f4bfe (mono-2.0-bdwgc) mono_jit_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/mini/mini-runtime.c:3445)
0x00007ff89222d254 (mono-2.0-bdwgc) do_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/metadata/object.c:3068)
0x00007ff89222d3cc (mono-2.0-bdwgc) mono_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/metadata/object.c:3115)
0x00007ff7a35303a4 (Unity) scripting_method_invoke
0x00007ff7a350e114 (Unity) ScriptingInvocation::Invoke
0x00007ff7a34f5904 (Unity) MonoBehaviour::CallMethodIfAvailable
0x00007ff7a34f5a2a (Unity) MonoBehaviour::CallUpdateMethod
0x00007ff7a2f88d8b (Unity) BaseBehaviourManager::CommonUpdate
0x00007ff7a2f902ea (Unity) BehaviourManager::Update
0x00007ff7a31c525d (Unity) InitPlayerLoopCallbacks'::2’::UpdateScriptRunBehaviourUpdateRegistrator::Forward
0x00007ff7a31a438c (Unity) ExecutePlayerLoop
0x00007ff7a31a4500 (Unity) ExecutePlayerLoop
0x00007ff7a31aad95 (Unity) PlayerLoop
0x00007ff7a4176f9f (Unity) PlayerLoopController::InternalUpdateScene
0x00007ff7a4183dcd (Unity) PlayerLoopController::UpdateSceneIfNeededFromMainLoop
0x00007ff7a41820b1 (Unity) Application::TickTimer
0x00007ff7a45fcd5a (Unity) MainMessageLoop
0x00007ff7a4601c30 (Unity) WinMain
0x00007ff7a59e2c1e (Unity) __scrt_common_main_seh
0x00007ff94cf7257d (KERNEL32) BaseThreadInitThunk
0x00007ff94dd2aa58 (ntdll) RtlUserThreadStart

I’m trying to submit a bug report but my project is rather large.

I wonder though, did something change in how A* Pathfinding uses physics within its jobs/burst stuff? Mainly asking to know how to possibly work around this.

A lot has changed in how a* uses burst since 4.2.
Though, the AIPath script hasn’t changed much in how it works. So I don’t think that should be the issue.

I know of at least 2 unity physics bugs (unrelated to this), that I’m waiting for to be able to enable higher performance stuff.