Search Unity

Looks like bug with Burst and ref bool in recursive function

Discussion in 'Burst' started by vitautart, Jan 10, 2019.

  1. vitautart

    vitautart

    Joined:
    May 3, 2018
    Posts:
    29
    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:
    417
    Thanks for the report. We will have a look at this issue.
     
  3. o1o1o1o1o2

    o1o1o1o1o2

    Joined:
    May 22, 2014
    Posts:
    34
    The same issue, no refs just using bool, no bool, no error
     
  4. xoofx

    xoofx

    Unity Technologies

    Joined:
    Nov 5, 2016
    Posts:
    417
    If you can have a try with the latest burst version 1.0.0-preview.4 ?