Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assertion fails during ComputeArgumentSize #1093

Closed
jvyden opened this issue Jul 27, 2023 · 7 comments
Closed

Assertion fails during ComputeArgumentSize #1093

jvyden opened this issue Jul 27, 2023 · 7 comments
Assignees
Labels

Comments

@jvyden
Copy link
Contributor

jvyden commented Jul 27, 2023

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
Copy link
Contributor Author

jvyden commented Jul 27, 2023

The line in question:

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

@jvyden
Copy link
Contributor Author

jvyden commented Jul 27, 2023

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
Copy link
Contributor Author

jvyden commented Jul 27, 2023

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?

@tgiphil
Copy link
Member

tgiphil commented Jul 28, 2023

@kiootic Hi! Can you help with this issue?

@tgiphil tgiphil added the Bug label Jul 28, 2023
@kiootic
Copy link
Contributor

kiootic commented Jul 28, 2023

This patch should fix the problem.
0001-Fix-ineffective-mapping-of-custom-argument-list.patch

@tgiphil
Copy link
Member

tgiphil commented Jul 28, 2023

Thank you!

@charsleysa
Copy link
Member

Fixed by b883129
Thanks @kiootic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

No branches or pull requests

4 participants