Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We've updated our Terms of Service. Please read our blog post from Unity CTO and Co-Founder Joachim Ante here
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Looks like bug with Burst and ref bool in recursive function

Discussion in 'Entity Component System and C# Job system' started by vitautart, Jan 10, 2019.

  1. vitautart

    vitautart

    Joined:
    May 3, 2018
    Posts:
    14
    Recently I used some functionality from PhilSA physics engine, and in recursive function I got exception. However Job works as expected. Also I use C-style boolean int32 (0, 1) to overcome this exception.

    Unexpected exception Burst.Compiler.IL.CompilerException: Error while verifying module: Stored value type does not match pointer operand type!
    store i32 0, i8* %var.5, align 1
    i8
    at Burst.Compiler.IL.NativeCompiler.Compile () [0x00321] in <37bebafd236f4ccd943dc039a926a017>:0
    at Burst.Compiler.IL.Jit.JitCompiler.CompileMethod (Mono.Cecil.MethodReference methodReference, Burst.Compiler.IL.Jit.JitOptions jitOptions) [0x001b6] in <37bebafd236f4ccd943dc039a926a017>:0
    at Burst.Compiler.IL.Jit.JitCompilerService.Compile (Burst.Compiler.IL.Jit.JitCompilerService+CompileJob job) [0x002b2] in <37bebafd236f4ccd943dc039a926a017>:0

    While compiling job: System.Void Unity.Jobs.IJobParallelForExtensions/ParallelForJobStruct`1<Simulation.PhysicsSystem/FindAgentObstacles>::Execute(T&,System.IntPtr,System.IntPtr,Unity.Jobs.LowLevel.Unsafe.JobRanges&,System.Int32)

    My simplified Code:

    Code (CSharp):
    1. [BurstCompile]
    2. public struct FindAgentObstacles : IJobParallelFor
    3. {
    4.     // Bunch of data
    5.  
    6.     void QueryBVHNode(int comparedToNode, AABB aabb, Entity entity, ref /* int */ bool alreadyInList)
    7.     {
    8.         if ( /* Bunch of bools*/ )
    9.         {
    10.             if (BVHArray[comparedToNode].FirstChildIndex < 0)
    11.             {
    12.                  // Bunch of code
    13.  
    14.                 //if (alreadyInList == 0)
    15.                 if (!alreadyInList)
    16.                 {
    17.                     collidingEntities.Enqueue(entity);
    18.                     //alreadyInList = 1;
    19.                     alreadyInList = true;
    20.                 }
    21.             }
    22.             else
    23.             {
    24.                 int firstChildIndex = BVHArray[comparedToNode].FirstChildIndex;
    25.                 QueryBVHNode(firstChildIndex, aabb, entity, ref alreadyInList);
    26.                 QueryBVHNode(firstChildIndex + 1, aabb, entity, ref alreadyInList);
    27.             }
    28.         }
    29.     }
    30.  
    31.     public void Execute(int index)
    32.     {
    33.         var chunk = chunks[index];
    34.  
    35.         NativeArray<Entity> entities = chunk.GetNativeArray(entityType);
    36.         NativeArray<AvoidanceRadius> avRadii = chunk.GetNativeArray(avoidanceRadiusType);
    37.         NativeArray<AABB> colidersAABBs = chunk.GetNativeArray(aabbType);
    38.  
    39.         for (int i = 0; i < chunk.Count; i++)
    40.         {
    41.             //int alreadyInList = 0;
    42.             bool alreadyInList = false;
    43.             AABB aabb = new AABB(colidersAABBs[i].center, avRadii[i].Value);
    44.             QueryBVHNode(1, aabb, entities[i], ref alreadyInList);
    45.             QueryBVHNode(2, aabb, entities[i], ref alreadyInList);
    46.         }
    47.     }
    48. }
     
  2. xoofx

    xoofx

    Unity Technologies

    Joined:
    Nov 5, 2016
    Posts:
    89
    Thanks for the report. We will have a look at this issue.