Search Unity

Burst Compiler Crash "Stack Empty"

Discussion in 'Burst' started by fholm, Feb 7, 2019.

  1. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,052
    Getting this error when trying to burst compile a generic job:

    Code (csharp):
    1.  
    2. Unexpected exception Burst.Compiler.IL.CompilerException: Unexpected exception ---> Burst.Compiler.IL.CompilerException: Error while processing function `System.Void NetCode.DeltaCompressorSystem/Job`1::Execute()` ---> Burst.Compiler.IL.CompilerException: Unexpected error while processing `IL_00dd: call System.Void NetCode.DeltaCompressorSystem::CheckField(NetCode.NetworkedEntityState*,System.Byte*,System.Byte*,NetCode.ReplicationFieldInfo) args(IL_00ad, IL_00c4, IL_00c5, IL_00d8)` at C:\Users\Fredrik\Documents\GitHub\ecsnetcode\ecsnetcode\Assets\NetCode\SerializerSystem.Serializer1.cs(96,19) ---> Burst.Compiler.IL.Syntax.BuilderException: Internal compiler error while processing function `System.Void NetCode.DeltaCompressorSystem::CheckField(NetCode.NetworkedEntityState*,System.Byte*,System.Byte*,NetCode.ReplicationFieldInfo)` ---> System.InvalidOperationException: Stack empty.
    3.   at System.Collections.Generic.Stack`1[T].ThrowForEmptyStack () [0x00000] in <3845a180c26b4889bc2d47593a665814>:0
    4.   at System.Collections.Generic.Stack`1[T].Peek () [0x00008] in <3845a180c26b4889bc2d47593a665814>:0
    5.   at Burst.Compiler.IL.Syntax.ILBuilder.Peek () [0x00000] in <37bebafd236f4ccd943dc039a926a017>:0
    6.   at Burst.Compiler.IL.Syntax.ILBuilder.ProcessInstruction (Mono.Cecil.Cil.Instruction inst) [0x00402] in <37bebafd236f4ccd943dc039a926a017>:0
    7.   at Burst.Compiler.IL.Syntax.ILBuilder.ProcessInstructions () [0x00092] in <37bebafd236f4ccd943dc039a926a017>:0
    8.    --- End of inner exception stack trace ---
    9.   at Burst.Compiler.IL.Syntax.ILBuilder.ThrowInternalError (System.Exception ex) [0x0002e] in <37bebafd236f4ccd943dc039a926a017>:0
    10.   at Burst.Compiler.IL.Syntax.ILBuilder.ProcessInstructions () [0x001fc] in <37bebafd236f4ccd943dc039a926a017>:0
    11.   at Burst.Compiler.IL.Syntax.ILBuilder.ProcessFunctionBody () [0x000b7] in <37bebafd236f4ccd943dc039a926a017>:0
    12.   at Burst.Compiler.IL.Syntax.ILBuilder.Visit (Burst.Compiler.IL.Syntax.MethodBinding binding) [0x00099] in <37bebafd236f4ccd943dc039a926a017>:0
    13.   at Burst.Compiler.IL.ILVisitor.PrepareFunctionInternal (Burst.Compiler.IL.Syntax.MethodBinding methodBinding) [0x00065] in <37bebafd236f4ccd943dc039a926a017>:0
    14.   at Burst.Compiler.IL.ILVisitor.PrepareFunction (Burst.Compiler.IL.Syntax.MethodBinding methodBinding) [0x00000] in <37bebafd236f4ccd943dc039a926a017>:0
    15.   at Burst.Compiler.IL.ILVerifier.PrepareFunction (Burst.Compiler.IL.Syntax.MethodBinding methodBinding) [0x00013] in <37bebafd236f4ccd943dc039a926a017>:0
    16.   at Burst.Compiler.IL.ILVisitor.GetFunction (Burst.Compiler.IL.Syntax.MethodBinding binding) [0x00016] in <37bebafd236f4ccd943dc039a926a017>:0
    17.   at Burst.Compiler.IL.ILVisitor.Call (Burst.Compiler.IL.Syntax.ILInstruction inst) [0x0007b] in <37bebafd236f4ccd943dc039a926a017>:0
    18.   at Burst.Compiler.IL.ILVisitor.CompileInternal (Burst.Compiler.IL.Syntax.ILInstruction inst) [0x003b0] in <37bebafd236f4ccd943dc039a926a017>:0
    19.   at Burst.Compiler.IL.ILVerifier.CompileInternal (Burst.Compiler.IL.Syntax.ILInstruction inst) [0x00018] in <37bebafd236f4ccd943dc039a926a017>:0
    20.   at Burst.Compiler.IL.ILVisitor.Compile (Burst.Compiler.IL.Syntax.ILInstruction inst) [0x0001e] in <37bebafd236f4ccd943dc039a926a017>:0
    21.   at Burst.Compiler.IL.ILVisitor.ProcessBlock (Burst.Compiler.IL.Syntax.ILBlock block) [0x0009a] in <37bebafd236f4ccd943dc039a926a017>:0
    22.    --- End of inner exception stack trace ---
    23.   at Burst.Compiler.IL.ILVisitor.ProcessBlock (Burst.Compiler.IL.Syntax.ILBlock block) [0x000e9] in <37bebafd236f4ccd943dc039a926a017>:0
    24.   at Burst.Compiler.IL.ILVisitor.ProcessBlocks () [0x0002e] in <37bebafd236f4ccd943dc039a926a017>:0
    25.   at Burst.Compiler.IL.ILVisitor.ProcessFunctionBody (Burst.Compiler.IL.Syntax.ILFunction function) [0x00103] in <37bebafd236f4ccd943dc039a926a017>:0
    26.   at Burst.Compiler.IL.ILVisitor.VisitPendingFunctions () [0x0000e] in <37bebafd236f4ccd943dc039a926a017>:0
    27.    --- End of inner exception stack trace ---
    28.   at Burst.Compiler.IL.ILVisitor.VisitPendingFunctions () [0x00033] in <37bebafd236f4ccd943dc039a926a017>:0
    29.   at Burst.Compiler.IL.ILVisitor.VisitEntryPointFunction (Burst.Compiler.IL.MethodReferenceWithHash methodReference) [0x00066] in <37bebafd236f4ccd943dc039a926a017>:0
    30.   at Burst.Compiler.IL.ILVisitor.VisitEntryPointFunction (Burst.Backend.Module module, Burst.Compiler.IL.MethodReferenceWithHash methodReference) [0x0001a] in <37bebafd236f4ccd943dc039a926a017>:0
    31.   at Burst.Compiler.IL.ILVerifier.VisitEntryPointFunction (Burst.Backend.Module module, Burst.Compiler.IL.MethodReferenceWithHash methodReference) [0x00000] in <37bebafd236f4ccd943dc039a926a017>:0
    32.    --- End of inner exception stack trace ---
    33.   at Burst.Compiler.IL.ILVerifier.VisitEntryPointFunction (Burst.Backend.Module module, Burst.Compiler.IL.MethodReferenceWithHash methodReference) [0x0001f] in <37bebafd236f4ccd943dc039a926a017>:0
    34.   at Burst.Compiler.IL.ILHash.CompileHash (Burst.Backend.Module module, Burst.Compiler.IL.MethodReferenceWithHash methodReference) [0x00000] in <37bebafd236f4ccd943dc039a926a017>:0
    35.   at Burst.Compiler.IL.NativeCompiler.ComputeHash () [0x000ea] in <37bebafd236f4ccd943dc039a926a017>:0
    36.   at Burst.Compiler.IL.Jit.JitCompiler.CompileMethod (Mono.Cecil.MethodReference methodReference, Burst.Compiler.IL.Jit.JitOptions jitOptions) [0x000aa] in <37bebafd236f4ccd943dc039a926a017>:0
    37.   at Burst.Compiler.IL.Jit.JitCompilerService.Compile (Burst.Compiler.IL.Jit.JitCompilerService+CompileJob job) [0x002b2] in <37bebafd236f4ccd943dc039a926a017>:0
    38.  
    39. While compiling job: System.Void Unity.Jobs.IJobExtensions/JobStruct`1<NetCode.DeltaCompressorSystem/Job`1<Unity.Transforms.Position>>::Execute(T&,System.IntPtr,System.IntPtr,Unity.Jobs.LowLevel.Unsafe.JobRanges&,System.Int32)
    40.  
    No clue where to go from here.

    Edit: It seems to be this part of the CheckField function it crashes on:

    Code (csharp):
    1.  
    2.         case ReplicationFieldType.Mathematics_Float3: {
    3.             var shd = (float3*)(s);
    4.             var val = *(float3*)(f);
    5.             var valShd = *shd;
    6.             if (c = (val.x != valShd.x || val.y != valShd.y || val.z != valShd.z)) {
    7.               *shd = val;
    8.             }
    9.           }
    10.           break;
    11.  
    Edit2: For reference this works fine with regular int/float (not float3 or quaternion):

    Code (csharp):
    1.  
    2.         case ReplicationFieldType.Int32: {
    3.             var shd = (Int32*)(s);
    4.             var val = *(Int32*)(f);
    5.             if (c = (val != *shd)) {
    6.               *shd = val;
    7.             }
    8.           }
    9.           break;
    10.         case ReplicationFieldType.Float: {
    11.             var shd = (Single*)(s);
    12.             var val = *(Single*)(f);
    13.             if (c = (val != *shd)) {
    14.               *shd = val;
    15.             }
    16.           }
    17.           break;
    18.  
    Edit3: Just for completeness sake the code runs fine under non-burst of course, and does exactly what its supposed to.
     
    Last edited: Feb 7, 2019