コガネブログ

平日更新を目標に Unity や C#、Visual Studio、ReSharper などのゲーム開発アレコレを書いていきます

【Unity】(0,0): Burst error BC0101: Unexpected error while processing function `XXXX.Unity.Jobs.IJob.Execute(XXXX* this) -> void_48866e3ad5c81254d9a4276b3d04e704 from YYYY, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null`: System.NullReferenceExceptio

概要

【Unity プロジェクト】\Library\PackageCache\com.unity.burst@1.7.4\.Runtime\bcl.exe exited after 980 ms.
Unexpected error while processing function `XXXX.Unity.Jobs.IJob.Execute(XXXX* this) -> void_48866e3ad5c81254d9a4276b3d04e704 from YYYYXXXX, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null`: System.NullReferenceException: �I�u�W�F�N�g�Q�Ƃ��I�u�W�F�N�g �C���X�^���X�ɐݒ肳��Ă��܂���B
   �ꏊ Burst.Compiler.IL.Syntax.ILSwitch.ToString()
   �ꏊ System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args)
   �ꏊ System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args)
   �ꏊ System.String.Format(String format, Object[] args)
   �ꏊ Burst.Compiler.IL.DiagnosticMessage..ctor(DiagnosticId diagnosticId, SourceLocation location, Object[] messageArgs, String callstack)
   �ꏊ Burst.Compiler.IL.Diagnostics.DiagnosticBag.Add(DiagnosticId diagnosticId, Nullable`1 location, Object[] messageArgs, ILInstruction currentInstruction)
   �ꏊ Burst.Compiler.IL.ILVisitor.LogMessage(DiagnosticId diagnosticId, Nullable`1 location, Object[] messageArgs)
   �ꏊ Burst.Compiler.IL.ILVisitor.LogException(Exception exception)
   �ꏊ Burst.Compiler.IL.ILVisitor.CatchException(Exception exception)
   �ꏊ Burst.Compiler.IL.ILVisitor.Visit(ILInstruction instruction)
   �ꏊ Burst.Compiler.IL.ILVisitor.VisitImpl(ILBlock block)
   �ꏊ Burst.Compiler.IL.ILVisitor.Visit(ILBlock block)
   �ꏊ Burst.Compiler.IL.ILVisitor.VisitBlocks()
   �ꏊ Burst.Compiler.IL.ILVisitor.VisitImpl(ILFunction ilFunction)
   �ꏊ Burst.Compiler.IL.ILCompiler.VisitImpl(ILFunction function)
   �ꏊ Burst.Compiler.IL.ILVisitor.Visit(ILFunction ilFunction)
 at Unity.Jobs.IJobExtensions.JobStruct`1<XXXX>.Execute(ref XXXX data, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, ref Unity.Jobs.LowLevel.Unsafe.JobRanges ranges, int jobIndex) (at /home/bokken/build/output/unity/unity/Runtime/Jobs/Managed/IJob.cs:23)
BuildFailedException: Burst compiler (1.7.4) failed running

stdout:
stderr:
(0,0): Burst error BC0101: Unexpected error while processing function `XXXX.Unity.Jobs.IJob.Execute(XXXX* this) -> void_48866e3ad5c81254d9a4276b3d04e704 from YYYY, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null`: System.NullReferenceException: �I�u�W�F�N�g�Q�Ƃ��I�u�W�F�N�g �C���X�^���X�ɐݒ肳��Ă��܂���B
   �ꏊ Burst.Compiler.IL.Syntax.ILSwitch.ToString()
   �ꏊ System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args)
   �ꏊ System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args)
   �ꏊ System.String.Format(String format, Object[] args)
   �ꏊ Burst.Compiler.IL.DiagnosticMessage..ctor(DiagnosticId diagnosticId, SourceLocation location, Object[] messageArgs, String callstack)
   �ꏊ Burst.Compiler.IL.Diagnostics.DiagnosticBag.Add(DiagnosticId diagnosticId, Nullable`1 location, Object[] messageArgs, ILInstruction currentInstruction)
   �ꏊ Burst.Compiler.IL.ILVisitor.LogMessage(DiagnosticId diagnosticId, Nullable`1 location, Object[] messageArgs)
   �ꏊ Burst.Compiler.IL.ILVisitor.LogException(Exception exception)
   �ꏊ Burst.Compiler.IL.ILVisitor.CatchException(Exception exception)
   �ꏊ Burst.Compiler.IL.ILVisitor.Visit(ILInstruction instruction)
   �ꏊ Burst.Compiler.IL.ILVisitor.VisitImpl(ILBlock block)
   �ꏊ Burst.Compiler.IL.ILVisitor.Visit(ILBlock block)
   �ꏊ Burst.Compiler.IL.ILVisitor.VisitBlocks()
   �ꏊ Burst.Compiler.IL.ILVisitor.VisitImpl(ILFunction ilFunction)
   �ꏊ Burst.Compiler.IL.ILCompiler.VisitImpl(ILFunction function)
   �ꏊ Burst.Compiler.IL.ILVisitor.Visit(ILFunction ilFunction)

 at Unity.Jobs.IJobExtensions.JobStruct`1<XXXX>.Execute(ref XXXX data, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, ref Unity.Jobs.LowLevel.Unsafe.JobRanges ranges, int jobIndex) (at /home/bokken/build/output/unity/unity/Runtime/Jobs/Managed/IJob.cs:23)

  at Unity.Burst.Editor.BurstAotCompiler+BclRunner.RunProgram (UnityEditor.Utils.Program p, System.String exe, System.String args, System.String workingDirectory, UnityEditor.Scripting.Compilers.CompilerOutputParserBase parser) [0x00237] in 【Unity プロジェクト】\Library\PackageCache\com.unity.burst@1.7.4\Editor\BurstAotCompiler.cs:1468 
  at Unity.Burst.Editor.BurstAotCompiler+BclRunner.RunManagedProgram (System.String exe, System.String args, System.String workingDirectory, UnityEditor.Scripting.Compilers.CompilerOutputParserBase parser) [0x0004d] in 【Unity プロジェクト】\Library\PackageCache\com.unity.burst@1.7.4\Editor\BurstAotCompiler.cs:1334 
  at Unity.Burst.Editor.BurstAotCompiler+BclRunner.RunManagedProgram (System.String exe, System.String args, UnityEditor.Scripting.Compilers.CompilerOutputParserBase parser) [0x00001] in 【Unity プロジェクト】\Library\PackageCache\com.unity.burst@1.7.4\Editor\BurstAotCompiler.cs:1309 
  at Unity.Burst.Editor.BurstAotCompiler.OnPostBuildPlayerScriptDLLsImpl (UnityEditor.Build.Reporting.BuildReport report) [0x00b0f] in 【Unity プロジェクト】\Library\PackageCache\com.unity.burst@1.7.4\Editor\BurstAotCompiler.cs:557 
  at Unity.Burst.Editor.BurstAotCompiler.OnPostBuildPlayerScriptDLLs (UnityEditor.Build.Reporting.BuildReport report) [0x0000e] in 【Unity プロジェクト】\Library\PackageCache\com.unity.burst@1.7.4\Editor\BurstAotCompiler.cs:208 
  at UnityEditor.Build.BuildPipelineInterfaces.OnPostBuildPlayerScriptDLLs (UnityEditor.Build.Reporting.BuildReport report) [0x00033] in <4ce403b7cdf744109283ae55cdc24285>:0 

(Filename: Library/PackageCache/com.unity.burst@1.7.4/Editor/BurstAotCompiler.cs Line: 1468)

DisplayProgressNotification: Build Failed
Error building Player: 18 errors

Job System を使用している Unity プロジェクトで Android IL2CPP ビルドしたら
上記のエラーが発生してビルドに失敗する現象に遭遇した

while ( true )
{
    // ...
}

IJob インターフェイスを実装している構造体の Execute 関数内で
上記のように while で無限ループを実装していた箇所を

while ( i1 < i2 )
{
    // ...
}

条件を満たしたらループを終了するようにしたらエラーが発生しなくなった