Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug Size Overflow in Allocator Unity crash

Discussion in 'Entity Component System' started by SFvdB, Jun 28, 2020.

  1. SFvdB

    SFvdB

    Joined:
    Mar 10, 2014
    Posts:
    27
    I've run into this Unity editor crash with only the Jobs package installed (not using Entities).

    It happens with the latest and one earlier version of the Jobs package. Version 0.2.10 and 0.2.9 both had this crash.

    I am using this in a project in Unity 2019.3.12f1 and I am on a Mac Pro (late 2013) on Mac OSX 10.14.6.

    It seems to happen when using Add() on a NativeList.

    I've attached the Unity editor log.

    It is caused by this piece of code, specifically the line within the while() loop, where it does path.Add(new int2()). I am not yet sure what's exactly causing it (either a problem with the cameFromNodeIndex or some such), but perhaps this helps create context.

    Code (CSharp):
    1.  
    2. // calculates the path once a path has been found (basically tracing back the steps through cameFromNodeIndex)
    3. private NativeList<int2> CalculatePath(NativeArray<PathNode> pathNodeArray, PathNode endNode)
    4.   {      
    5.         if (endNode.cameFromNodeIndex == -1)
    6.         {
    7.             // could not find a path
    8.             return new NativeList<int2>(Allocator.Temp);
    9.         }
    10.         else
    11.         {
    12.             // found a path!
    13.             // create a list we call path to return
    14.             NativeList<int2> path = new NativeList<int2>(Allocator.Temp);
    15.            
    16.             // first, add the endNode (first of our path, which is backwards)
    17.             path.Add(new int2(endNode.x, endNode.y));
    18.  
    19.             // loop through all the nodes using the indexes we encounter walking backwards
    20.             PathNode currentNode = endNode;
    21.            
    22.             // while we have a valid index we loop:
    23.             while (currentNode.cameFromNodeIndex != -1)
    24.             {
    25.                 // get the node from the pathNodeArray with this index
    26.                 PathNode cameFromNode = pathNodeArray[currentNode.cameFromNodeIndex];
    27.                
    28.                 // add it to our path list
    29.                 path.Add(new int2(cameFromNode.x, cameFromNode.y));
    30.                
    31.                 // set the currentNode to the one we just encountered
    32.                 currentNode = cameFromNode;
    33.             }
    34.  
    35.             return path;
    36.         }
    37.     }
    FYI: The pathfinding code is based on code written by Code Monkey as in his DOTS Pathfinding tutorials. Although I am modifying it to suit my needs.
     

    Attached Files:

  2. vectorized-runner

    vectorized-runner

    Joined:
    Jan 22, 2018
    Posts:
    383
    I'm guessing its happening because your while loop never terminates
     
  3. SFvdB

    SFvdB

    Joined:
    Mar 10, 2014
    Posts:
    27
    Yes after posting this I've too come to the conclusion that this is very likely - I will test it soon and post an update.
     
  4. SFvdB

    SFvdB

    Joined:
    Mar 10, 2014
    Posts:
    27
    So yeah false alarm, it was my own faulty code. This topic can be deleted/moved/closed. Sorry for the hubbub!