Unity crashes on PolygonCollider2D setPath

Hi, while working on a deformable collapsible 2D terrain, I have a problem with the Unity desktop editor crashing only at certain times (have not been reliably able to reproduce the bug, just random).

Here is the stack dump

========== OUTPUTING STACK TRACE ==================


(0x00B1B5D7) c:\buildagent\work\d3d49558e4d408f4\runtime\physics2d\polygoncolliderbase2d.cpp (301 + 0x7): PolygonColliderBase2D::ValidatePolygonShape + 0x807
(0x00B1C370) c:\buildagent\work\d3d49558e4d408f4\runtime\physics2d\polygoncolliderbase2d.cpp (163 + 0xa): PolygonColliderBase2D::ExtractConvexShapes + 0x490
(0x00B1C583) c:\buildagent\work\d3d49558e4d408f4\runtime\physics2d\polygoncolliderbase2d.cpp (68 + 0x16): PolygonColliderBase2D::Create + 0xf3
(0x00B1C63F) c:\buildagent\work\d3d49558e4d408f4\runtime\physics2d\polygoncollider2d.cpp (98 + 0x0): PolygonCollider2D::RefreshPoly + 0xf
(0x150A41E9) (Mono JIT code): (filename not available):  (wrapper managed-to-native) UnityEngine.PolygonCollider2D:SetPath (int,UnityEngine.Vector2[]) + 0x89 (150A4160 150A4239) [09B96BD0 - Unity Child Domain] + 0x0
(0x15038C4B) (Mono JIT code): (filename not available):  NetworkManager:Update () + 0x6b3 (15038598 15038CD2) [09B96BD0 - Unity Child Domain] + 0x0
(0x0AFBBE1F) (Mono JIT code): (filename not available):  (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr) + 0x8f (0AFBBD90 0AFBBEEA) [09B96BD0 - Unity Child Domain] + 0x0
(0x09A4FEDE) c:\buildslave\monoandruntimeclasslibs\build\mono\mini\mini.c (4889 + 0xc): mono_jit_runtime_invoke + 0x214
(0x099BD680) c:\buildslave\monoandruntimeclasslibs\build\mono\metadata\object.c (2618 + 0x10): mono_runtime_invoke + 0x51
(0x00706EF8) c:\buildagent\work\d3d49558e4d408f4\runtime\scripting\backend\mono\scriptingbackendapi_mono.cpp (183 + 0x1a): scripting_method_invoke + 0xb8
(0x0082740C) c:\buildagent\work\d3d49558e4d408f4\runtime\scripting\backend\scriptinginvocationnoargs.cpp (97 + 0x0): ScriptingInvocationNoArgs::Invoke + 0x6c
(0x00826BC5) c:\buildagent\work\d3d49558e4d408f4\runtime\scripting\backend\scriptinginvocation.cpp (94 + 0x0): ScriptingInvocation::Invoke + 0x15
(0x006F4F94) c:\buildagent\work\d3d49558e4d408f4\runtime\mono\monobehaviour.cpp (529 + 0xb): MonoBehaviour::CallMethodIfAvailable + 0xf4
(0x006F52B9) c:\buildagent\work\d3d49558e4d408f4\runtime\mono\monobehaviour.cpp (611 + 0xb): MonoBehaviour::CallUpdateMethod + 0xf9
(0x006F52D7) c:\buildagent\work\d3d49558e4d408f4\runtime\mono\monobehaviour.cpp (617 + 0x0): MonoBehaviour::Update + 0x7
(0x007DD887) c:\buildagent\work\d3d49558e4d408f4\runtime\misc\player.cpp (1927 + 0x0): PlayerLoop + 0x4a7
(0x00F654FC) c:\buildagent\work\d3d49558e4d408f4\editor\src\application.cpp (2286 + 0xb): Application::UpdateScene + 0x21c
(0x00F69577) c:\buildagent\work\d3d49558e4d408f4\editor\src\application.cpp (2216 + 0x0): Application::UpdateSceneIfNeeded + 0x37
(0x0100C682) c:\buildagent\work\d3d49558e4d408f4\editor\platform\windows\wineditormain.cpp (336 + 0x0): MainMessageLoop + 0x1c2
(0x0100D5C7) c:\buildagent\work\d3d49558e4d408f4\editor\platform\windows\wineditormain.cpp (848 + 0x0): WinMain + 0xe37
(0x01125C34) f:\dd\vctools\crt_bld\self_x86\crt\src\crt0.c (275 + 0x1c): __tmainCRTStartup + 0x11a
(0x75A3495D) (KERNEL32): (filename not available): BaseThreadInitThunk + 0xe
(0x770698EE) (ntdll): (filename not available): RtlInitializeExceptionChain + 0x84
(0x770698C4) (ntdll): (filename not available): RtlInitializeExceptionChain + 0x5a


========== END OF STACKTRACE ===========

What I have is a custom set of vertices (Vector2 points) I’m generating a collider with, and then changing the Vector2’s that are affected by an explosion before using setPath to update the collider. The updating itself works fine and forms to the terrain without problems, with the exception of the crashes.

As this is somewhat likely to be a problem with the generated path, what are the specifics for a PolygonCollider2D path, generated from vertices? The only thing I’ve been able to gather is that the path needs to fully encircle / enclose a shape, which it is doing. Any suggestions?

I have encounter similar issue, it seems when your path shapes has intersects, it crash, i have shrinked all the paths a little, then it will be fine.