corert icon indicating copy to clipboard operation
corert copied to clipboard

Unhandled Exception: ILCompiler.CodeGenerationFailedException: Code generation failed for method

Open Powerlated opened this issue 5 years ago • 2 comments
trafficstars

Unhandled Exception: Unhandled Exception: Unhandled Exception: Unhandled Exception: Unhandled Exception: Unhandled Exception: Unhandled Exception: Unhandled Exception: Unhandled Exception:
  Unhandled Exception:
  Unhandled Exception:
  Unhandled Exception: ILCompiler.CodeGenerationFailedException: Code generation failed for method '[OpenTK]OpenTK.Graphics.ES30.GL+Qcom.ExtGetProgramBinarySource(int32,ShaderType,string&,int32[])'
     at Internal.JitInterface.CorInfoImpl.CompileMethodInternal(IMethodNode methodCodeNodeNeedingCode, MethodIL methodIL)
     at Internal.JitInterface.CorInfoImpl.CompileMethod(MethodCodeNode methodCodeNodeNeedingCode, MethodIL methodIL)
     at ILCompiler.RyuJitCompilation.CompileSingleMethod(CorInfoImpl corInfo, MethodCodeNode methodCodeNodeNeedingCode)
     at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
  --- End of stack trace from previous location where exception was thrown ---
     at System.Threading.ThreadPoolWorkQueue.Dispatch()
  ILCompiler.CodeGenerationFailedException: Code generation failed for method '[OpenTK]OpenTK.Graphics.ES30.GL+Qcom.ExtGetProgramBinarySource(uint32,ShaderType,string&,int32&)'
     at Internal.JitInterface.CorInfoImpl.CompileMethodInternal(IMethodNode methodCodeNodeNeedingCode, MethodIL methodIL)
     at Internal.JitInterface.CorInfoImpl.CompileMethod(MethodCodeNode methodCodeNodeNeedingCode, MethodIL methodIL)
     at ILCompiler.RyuJitCompilation.CompileSingleMethod(CorInfoImpl corInfo, MethodCodeNode methodCodeNodeNeedingCode)
     at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
  --- End of stack trace from previous location where exception was thrown ---
     at System.Threading.ThreadPoolWorkQueue.Dispatch()
  ILCompiler.CodeGenerationFailedException: Code generation failed for method '[OpenTK]OpenTK.Graphics.ES30.GL+Qcom.ExtGetProgramBinarySource(int32,ShaderType,string&,int32*)'
     at Internal.JitInterface.CorInfoImpl.CompileMethodInternal(IMethodNode methodCodeNodeNeedingCode, MethodIL methodIL)
     at Internal.JitInterface.CorInfoImpl.CompileMethod(MethodCodeNode methodCodeNodeNeedingCode, MethodIL methodIL)
     at ILCompiler.RyuJitCompilation.CompileSingleMethod(CorInfoImpl corInfo, MethodCodeNode methodCodeNodeNeedingCode)
     at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
  --- End of stack trace from previous location where exception was thrown ---
     at System.Threading.ThreadPoolWorkQueue.Dispatch()
  ILCompiler.CodeGenerationFailedException: Code generation failed for method '[OpenTK]OpenTK.Graphics.ES30.GL+Qcom.ExtGetProgramBinarySource(int32,All,string&,int32[])'
     at Internal.JitInterface.CorInfoImpl.CompileMethodInternal(IMethodNode methodCodeNodeNeedingCode, MethodIL methodIL)
     at Internal.JitInterface.CorInfoImpl.CompileMethod(MethodCodeNode methodCodeNodeNeedingCode, MethodIL methodIL)
     at ILCompiler.RyuJitCompilation.CompileSingleMethod(CorInfoImpl corInfo, MethodCodeNode methodCodeNodeNeedingCode)
     at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
  --- End of stack trace from previous location where exception was thrown ---
     at System.Threading.ThreadPoolWorkQueue.Dispatch()
  ILCompiler.CodeGenerationFailedException: Code generation failed for method '[OpenTK]OpenTK.Graphics.ES30.GL+Qcom.ExtGetProgramBinarySource(uint32,ShaderType,string&,int32[])'
     at Internal.JitInterface.CorInfoImpl.CompileMethodInternal(IMethodNode methodCodeNodeNeedingCode, MethodIL methodIL)
     at Internal.JitInterface.CorInfoImpl.CompileMethod(MethodCodeNode methodCodeNodeNeedingCode, MethodIL methodIL)
     at ILCompiler.RyuJitCompilation.CompileSingleMethod(CorInfoImpl corInfo, MethodCodeNode methodCodeNodeNeedingCode)
     at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
  --- End of stack trace from previous location where exception was thrown ---
     at System.Threading.ThreadPoolWorkQueue.Dispatch()
  ILCompiler.CodeGenerationFailedException: Code generation failed for method '[OpenTK]OpenTK.Graphics.ES30.GL+Qcom.ExtGetProgramBinarySource(int32,All,string&,int32*)'
     at Internal.JitInterface.CorInfoImpl.CompileMethodInternal(IMethodNode methodCodeNodeNeedingCode, MethodIL methodIL)
     at Internal.JitInterface.CorInfoImpl.CompileMethod(MethodCodeNode methodCodeNodeNeedingCode, MethodIL methodIL)
     at ILCompiler.RyuJitCompilation.CompileSingleMethod(CorInfoImpl corInfo, MethodCodeNode methodCodeNodeNeedingCode)
     at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
  --- End of stack trace from previous location where exception was thrown ---
     at System.Threading.ThreadPoolWorkQueue.Dispatch()
  ILCompiler.CodeGenerationFailedException: Code generation failed for method '[OpenTK]OpenTK.Graphics.ES30.GL+Qcom.ExtGetProgramBinarySource(uint32,All,string&,int32&)'
     at Internal.JitInterface.CorInfoImpl.CompileMethodInternal(IMethodNode methodCodeNodeNeedingCode, MethodIL methodIL)
     at Internal.JitInterface.CorInfoImpl.CompileMethod(MethodCodeNode methodCodeNodeNeedingCode, MethodIL methodIL)
     at ILCompiler.RyuJitCompilation.CompileSingleMethod(CorInfoImpl corInfo, MethodCodeNode methodCodeNodeNeedingCode)
     at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
  --- End of stack trace from previous location where exception was thrown ---
     at System.Threading.ThreadPoolWorkQueue.Dispatch()ILCompiler.CodeGenerationFailedException: Code generation failed for method '[OpenTK]OpenTK.Graphics.ES30.GL+Qcom.ExtGetProgramBinarySource(uint32,All,string&,int32*)'
     at Internal.JitInterface.CorInfoImpl.CompileMethodInternal(IMethodNode methodCodeNodeNeedingCode, MethodIL methodIL)
     at Internal.JitInterface.CorInfoImpl.CompileMethod(MethodCodeNode methodCodeNodeNeedingCode, MethodIL methodIL)
     at ILCompiler.RyuJitCompilation.CompileSingleMethod(CorInfoImpl corInfo, MethodCodeNode methodCodeNodeNeedingCode)
     at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
  --- End of stack trace from previous location where exception was thrown ---
     at System.Threading.ThreadPoolWorkQueue.Dispatch()ILCompiler.CodeGenerationFailedException: Code generation failed for method '[OpenTK]OpenTK.Graphics.ES30.GL+Qcom.ExtGetProgramBinarySource(uint32,ShaderType,string&,int32*)'
     at Internal.JitInterface.CorInfoImpl.CompileMethodInternal(IMethodNode methodCodeNodeNeedingCode, MethodIL methodIL)
     at Internal.JitInterface.CorInfoImpl.CompileMethod(MethodCodeNode methodCodeNodeNeedingCode, MethodIL methodIL)
     at ILCompiler.RyuJitCompilation.CompileSingleMethod(CorInfoImpl corInfo, MethodCodeNode methodCodeNodeNeedingCode)
     at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
  --- End of stack trace from previous location where exception was thrown ---
     at System.Threading.ThreadPoolWorkQueue.Dispatch()ILCompiler.CodeGenerationFailedException: Code generation failed for method '[OpenTK]OpenTK.Graphics.ES30.GL+Qcom.ExtGetProgramBinarySource(int32,ShaderType,string&,int32&)'
     at Internal.JitInterface.CorInfoImpl.CompileMethodInternal(IMethodNode methodCodeNodeNeedingCode, MethodIL methodIL)
     at Internal.JitInterface.CorInfoImpl.CompileMethod(MethodCodeNode methodCodeNodeNeedingCode, MethodIL methodIL)
     at ILCompiler.RyuJitCompilation.CompileSingleMethod(CorInfoImpl corInfo, MethodCodeNode methodCodeNodeNeedingCode)
     at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
  --- End of stack trace from previous location where exception was thrown ---
     at System.Threading.ThreadPoolWorkQueue.Dispatch()ILCompiler.CodeGenerationFailedException: Code generation failed for method '[OpenTK]OpenTK.Graphics.ES30.GL+Qcom.ExtGetProgramBinarySource(uint32,All,string&,int32[])'
     at Internal.JitInterface.CorInfoImpl.CompileMethodInternal(IMethodNode methodCodeNodeNeedingCode, MethodIL methodIL)
     at Internal.JitInterface.CorInfoImpl.CompileMethod(MethodCodeNode methodCodeNodeNeedingCode, MethodIL methodIL)
     at ILCompiler.RyuJitCompilation.CompileSingleMethod(CorInfoImpl corInfo, MethodCodeNode methodCodeNodeNeedingCode)
     at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
  --- End of stack trace from previous location where exception was thrown ---
     at System.Threading.ThreadPoolWorkQueue.Dispatch()ILCompiler.CodeGenerationFailedException: Code generation failed for method '[OpenTK]OpenTK.Graphics.ES30.GL+Qcom.ExtGetProgramBinarySource(int32,All,string&,int32&)'
     at Internal.JitInterface.CorInfoImpl.CompileMethodInternal(IMethodNode methodCodeNodeNeedingCode, MethodIL methodIL)
     at Internal.JitInterface.CorInfoImpl.CompileMethod(MethodCodeNode methodCodeNodeNeedingCode, MethodIL methodIL)
     at ILCompiler.RyuJitCompilation.CompileSingleMethod(CorInfoImpl corInfo, MethodCodeNode methodCodeNodeNeedingCode)
     at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
  --- End of stack trace from previous location where exception was thrown ---
     at System.Threading.ThreadPoolWorkQueue.Dispatch()

I am attempting to dotnet publish -r win-x64 -c Release a program and I receieve this error after the Generating compatible native code. message.

Powerlated avatar Sep 21 '20 03:09 Powerlated

OpenTK assembly contains invalid IL:

    .method public hidebysig static void 
            ExtGetProgramBinarySource(int32 program,
                                      valuetype OpenTK.Graphics.ES30.All shadertype,
                                      [out] string& source,
                                      [out] int32[] length) cil managed
    {
      .maxstack  7
      .locals init (native int V_0,
               int32 V_1,
               int32& pinned V_2)
      IL_0000:  ldarg.0
      IL_0001:  ldarg.1
      IL_0002:  ldarg.2
      IL_0003:  pop
      IL_0004:  ldarg.3 <- the type of 3rd argument is `int32[]`
      IL_0005:  ldind.i4 <- ldind.i4 on `int32[]` is invalid IL operation
...

(This is just one example. There are more.)

It is crashing the JIT with CORJIT_INTERNALERROR and in turn crashing the compiler.

jkotas avatar Sep 22 '20 06:09 jkotas

OpenTK project is using IL generator https://github.com/opentk/opentk/tree/master/src/Generator.Rewrite that seems to be responsible for the invalid IL.

We should look into reporting this error in a better way, but the underlying problem should be fixed in OpenTK project. @Powerlated Could you please open an issue on this in OpenTK project?

jkotas avatar Sep 22 '20 06:09 jkotas