mosa/MOSA-Project

Assertion fails during ComputeArgumentSize

jvyden opened this issue · 7 comments

jvyden commented

image

Unsure how to reproduce, but it happens during compilation in the mosa branch of my project (https://github.com/jvyden/BoringOS) under my MOSA-Project fork.

/usr/bin/dotnet Tools/Mosa.Tool.Launcher.dll BoringOS.MOSA.dll
Process terminated. Assertion failed.
   at Mosa.Compiler.Framework.CompilerStages.MetadataStage.ComputeArgumentSize(MosaType type, Object value)
   at Mosa.Compiler.Framework.CompilerStages.MetadataStage.CreateCustomAttributeArgument(String name, Int32 count, String argName, Argument arg, Boolean isField)
   at Mosa.Compiler.Framework.CompilerStages.MetadataStage.CreateCustomAttribute(MosaUnit unit, MosaCustomAttribute ca, Int32 position)
   at Mosa.Compiler.Framework.CompilerStages.MetadataStage.CreateCustomAttributesTable(MosaUnit unit)
   at Mosa.Compiler.Framework.CompilerStages.MetadataStage.CreateFieldDefinitions(MosaType type)
   at Mosa.Compiler.Framework.CompilerStages.MetadataStage.CreateTypeDefinition(MosaType type, LinkerSymbol assemblyTableSymbol)
   at Mosa.Compiler.Framework.CompilerStages.MetadataStage.CreateAssemblyDefinition(MosaModule module)
   at Mosa.Compiler.Framework.CompilerStages.MetadataStage.CreateDefinitionTables()
   at Mosa.Compiler.Framework.CompilerStages.MetadataStage.Finalization()
   at Mosa.Compiler.Framework.BaseCompilerStage.ExecuteFinalization()
   at Mosa.Compiler.Framework.Compiler.Finalization()
   at Mosa.Compiler.Framework.MosaCompiler.Finalization()
   at Mosa.Compiler.Framework.MosaCompiler.Compile(Boolean skipFinalization)
   at Mosa.Utility.Launcher.Builder.Compile()
   at Mosa.Utility.Launcher.Builder.Build()
   at Mosa.Tool.Launcher.MainWindow.<CompileBuildAndStart>b__21_0(Object _)
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()

Process finished with exit code 134.
jvyden commented

The line in question:

Debug.Assert(value is MosaCustomAttribute.Argument[]);

jvyden commented

Seems to happen while trying to compile the NullableAttribute.

In MetadataStage.CreateCustomAttributeArgument(), attributeName evaluates to

BoringOS.BoringKernel+<>c__DisplayClass14_0::programs System.Collections.Generic.List`1<BoringOS.Programs.Program>>>0:NullableAttribute:0

jvyden commented

Narrowing it down further, it seems to be this line:
https://github.com/jvyden/BoringOS/blob/mosa/BoringOS/BoringKernel.cs#L101

Marking the BoringKernel class as non-nullable with #nullable disable lets the compilation process succeed!

So, defining List<Program> causes the compiler to crash for some reason. Seems it's passing down a raw list of arguments from dnlib?

@kiootic Hi! Can you help with this issue?

Thank you!

Fixed by b883129
Thanks @kiootic