Skip to content

Making an action point to a virtual void makes IL2CPU crash #2941

Open
@9xbt

Description

@9xbt

Have you checked Github Issues for similar errors?
Yes

Exception

Exception: System.Exception: Error compiling method 'A0SystemVoidA8CosmosKernel15KernelBeforeRun': System.ArgumentNullException: Value cannot be null. (Parameter 'aType')

Visual Studio Output Logs

Build started...
1>------ Build started: Project: CosmosKernel15, Configuration: Debug Any CPU ------
1>Skipping analyzers to speed up the build. You can execute 'Build' or 'Rebuild' command to run analyzers.
1>CosmosKernel15 -> C:\Users\Eric\source\repos\CosmosKernel15\CosmosKernel15\bin\Debug\net6.0\CosmosKernel15.dll
1>Executing IL2CPU on assembly
1>Kernel Base: Cosmos.System.Kernel
1>Checking target assembly: C:\Users\Eric\source\repos\CosmosKernel15\CosmosKernel15\bin\Debug\net6.0\CosmosKernel15.dll
1>IL2CPU : warning : Loading plugs from assembly: Cosmos.Core_Asm, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983
1>IL2CPU : warning : Loading plugs from assembly: Cosmos.Core_Plugs, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983
1>IL2CPU : warning : Loading plugs from assembly: Cosmos.Debug.Kernel.Plugs.Asm, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983
1>IL2CPU : warning : Loading plugs from assembly: Cosmos.System2_Plugs, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983
1>IL2CPU : warning : Invalid plug method! Target method not found. : A0SystemInt64A2CosmosSystem_PlugsSystemIOOSFileStreamStrategyImplSeekA0SystemInt64A0SystemObject
1>IL2CPU : warning : Invalid plug method! Target method not found. : A0SystemVoidA2CosmosSystem_PlugsSystemIOStreamWriterImplWriteFormatHelperA0SystemStringA0A0SystemObjectarrayA0SystemBoolean
1>Detecting fields for type 'IL2CPU.Debug.Symbols.FIELD_INFO'
1>Detecting fields for type 'IL2CPU.Debug.Symbols.FIELD_MAPPING'
1>IL2CPU : error : Exception: System.Exception: Error compiling method 'A0SystemVoidA8CosmosKernel15KernelBeforeRun': System.ArgumentNullException: Value cannot be null. (Parameter 'aType')
1>   at Cosmos.IL2CPU.ILOp.SizeOfType(Type aType) in C:\Users\Eric\Documents\GitHub\Cosmos\IL2CPU\source\Cosmos.IL2CPU\ILOp.cs:line 627
1>   at Cosmos.IL2CPU.ILOpCode.DoStackAnalysis(Stack`1 aStack, UInt32& aStackOffset) in C:\Users\Eric\Documents\GitHub\Cosmos\IL2CPU\source\Cosmos.IL2CPU\ILOpCode.cs:line 349
1>   at Cosmos.IL2CPU.MethodAnalysis.ILMethod.Analyse() in C:\Users\Eric\Documents\GitHub\Cosmos\IL2CPU\source\Cosmos.IL2CPU\MethodAnalysis\ILMethod.cs:line 48
1>   at Cosmos.IL2CPU.AppAssembler.AnalyseMethodOpCodes(Il2cpuMethodInfo aMethod, List`1 aOpCodes) in C:\Users\Eric\Documents\GitHub\Cosmos\IL2CPU\source\Cosmos.IL2CPU\AppAssembler.cs:line 493
1>   at Cosmos.IL2CPU.AppAssembler.ProcessMethod(Il2cpuMethodInfo aMethod, List`1 aOpCodes, PlugManager aPlugManager) in C:\Users\Eric\Documents\GitHub\Cosmos\IL2CPU\source\Cosmos.IL2CPU\AppAssembler.cs:line 474
1> ---> System.ArgumentNullException: Value cannot be null. (Parameter 'aType')
1>   at Cosmos.IL2CPU.ILOp.SizeOfType(Type aType) in C:\Users\Eric\Documents\GitHub\Cosmos\IL2CPU\source\Cosmos.IL2CPU\ILOp.cs:line 627
1>   at Cosmos.IL2CPU.ILOpCode.DoStackAnalysis(Stack`1 aStack, UInt32& aStackOffset) in C:\Users\Eric\Documents\GitHub\Cosmos\IL2CPU\source\Cosmos.IL2CPU\ILOpCode.cs:line 349
1>   at Cosmos.IL2CPU.MethodAnalysis.ILMethod.Analyse() in C:\Users\Eric\Documents\GitHub\Cosmos\IL2CPU\source\Cosmos.IL2CPU\MethodAnalysis\ILMethod.cs:line 48
1>   at Cosmos.IL2CPU.AppAssembler.AnalyseMethodOpCodes(Il2cpuMethodInfo aMethod, List`1 aOpCodes) in C:\Users\Eric\Documents\GitHub\Cosmos\IL2CPU\source\Cosmos.IL2CPU\AppAssembler.cs:line 493
1>   at Cosmos.IL2CPU.AppAssembler.ProcessMethod(Il2cpuMethodInfo aMethod, List`1 aOpCodes, PlugManager aPlugManager) in C:\Users\Eric\Documents\GitHub\Cosmos\IL2CPU\source\Cosmos.IL2CPU\AppAssembler.cs:line 474
1>   --- End of inner exception stack trace ---
1>   at Cosmos.IL2CPU.AppAssembler.ProcessMethod(Il2cpuMethodInfo aMethod, List`1 aOpCodes, PlugManager aPlugManager) in C:\Users\Eric\Documents\GitHub\Cosmos\IL2CPU\source\Cosmos.IL2CPU\AppAssembler.cs:line 483
1>   at Cosmos.IL2CPU.ILScanner.Assemble() in C:\Users\Eric\Documents\GitHub\Cosmos\IL2CPU\source\Cosmos.IL2CPU\ILScanner.cs:line 979
1>   at Cosmos.IL2CPU.ILScanner.Execute(MethodBase aStartMethod, IEnumerable`1 plugsAssemblies) in C:\Users\Eric\Documents\GitHub\Cosmos\IL2CPU\source\Cosmos.IL2CPU\ILScanner.cs:line 272
1>   at Cosmos.IL2CPU.CompilerEngine.Execute() in C:\Users\Eric\Documents\GitHub\Cosmos\IL2CPU\source\Cosmos.IL2CPU\CompilerEngine.cs:line 187
1>IL2CPU task took 00:00:01.2702875
1>Done building project "CosmosKernel15.csproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Elapsed 00:01.965 ==========

How To Reproduce
Set an action to point to a virtual void. For example:

using System;
using Sys = Cosmos.System;

namespace CosmosKernel15
{
    public class Kernel : Sys.Kernel
    {
        protected override void BeforeRun()
        {
            Action action = Test;
        }

        protected override void Run() { }

        public bool a;

        public virtual void Test()
            => a = true;
    }
}

Screenshots

Context
Before posting please confirm that the following are in order
[Y] Both Cosmos VS Extensions are installed
[Y] In the NuGet Package Manager "Include prerelease" is selected
[Y] The Cosmos NuGet package store is selected (NOT nuget.org) in 'Manage NuGet Packages'
[Y] The Cosmos NuGet packages are installed

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions