Yellow-Dog-Man / Resonite-Issues

Issue repository for Resonite.
https://resonite.com
140 stars 2 forks source link

Loading any plugins broken on Headless leading to crash #3028

Closed XDelta closed 1 month ago

XDelta commented 1 month ago

Describe the bug?

When attempting to launch the latest headless with any LoadAssembly arg (Plugin), it seems to be crashing with a stack overflow before loading the plugins

To Reproduce

Run the latest headless with any LoadAssembly arg that is set to a valid plugin dll.

For example Resonite.exe -LoadAssembly Libraries\ResoniteModLoader.dll but I've additionally checked with very barebones plugin to confirm it isn't just an issue with RML. The headless will get as far as 'Processing startup commands...' then hit a stack overflow

Expected behavior

The plugin code to be called and used.

Resonite Version Number

2024.9.30.1216

What Platforms does this occur on?

Windows

Log Files

AppPath: R:\SteamLibrary\steamapps\common\Resonite\Headless
DataPath: V:\ResoniteHeadless
CachePath: V:\ResoniteHeadless
Initializing App: Beta 2024.9.30.1216
Platform: Windows
HeadDevice: Headless
IsAOT: False
OS: Microsoft Windows 10 Pro
CPU: AMD Ryzen 7 7800X3D 8-Core Processor
GPU: Parsec Virtual Display Adapter
PhysicalCores: 8
MemoryBytes: 63.22 GB
VRAMBytes: 0.00 B
MaxTextureSize: 16384
IsGPUTexturePOTByteAligned: True
UsingLinearSpace: False
XR Device Name:
XR Device Model:
StereoRenderingMode:
Max GC Generation: 2, IsLittleEndian: True
System.Numerics.Vectors HW accelerated: True, Vector<float>.Count: 8
Brotli native encoding/decoding supported: True
Supported Texture Formats: Unknown, Alpha8, R8, RGB24, ARGB32, RGBA32, BGRA32, RGB565, RGBAHalf, ARGBHalf, RHalf, RGHalf, RGBAFloat, ARGBFloat, RFloat, RGFloat, BC1, BC2, BC3, BC4, BC5, BC6H, BC7, ETC2_RGB, ETC2_RGBA1, ETC2_RGBA8, ASTC_4x4, ASTC_5x5, ASTC_6x6, ASTC_8x8, ASTC_10x10, ASTC_12x12
Processing startup commands...
Stack overflow.
   at Mono.Cecil.Metadata.RowEqualityComparer.GetHashCode(Mono.Cecil.Metadata.Row`2<System.String,System.String>)
   at System.Collections.Generic.Dictionary`2[[Mono.Cecil.Metadata.Row`2[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], Mono.Cecil, Version=0.11.5.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e],[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].FindValue(Mono.Cecil.Metadata.Row`2<System.__Canon,System.__Canon>)
   at System.Collections.Generic.Dictionary`2[[Mono.Cecil.Metadata.Row`2[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], Mono.Cecil, Version=0.11.5.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e],[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].TryGetValue(Mono.Cecil.Metadata.Row`2<System.__Canon,System.__Canon>, System.__Canon ByRef)
   at Mono.Cecil.TypeDefinitionCollection.GetType(System.String, System.String)
   at Mono.Cecil.ModuleDefinition.GetType(System.String, System.String)
   at Mono.Cecil.MetadataResolver.GetTypeDefinition(Mono.Cecil.ModuleDefinition, Mono.Cecil.TypeReference)
   at Mono.Cecil.MetadataResolver.GetType(Mono.Cecil.ModuleDefinition, Mono.Cecil.TypeReference)
   at Mono.Cecil.MetadataResolver.Resolve(Mono.Cecil.TypeReference)
   at Mono.Cecil.ModuleDefinition.Resolve(Mono.Cecil.TypeReference)
   at Mono.Cecil.ExportedType.Resolve()
   at Mono.Cecil.MetadataResolver.GetType(Mono.Cecil.ModuleDefinition, Mono.Cecil.TypeReference)
   at Mono.Cecil.MetadataResolver.Resolve(Mono.Cecil.TypeReference)
   at Mono.Cecil.ModuleDefinition.Resolve(Mono.Cecil.TypeReference)
   at Mono.Cecil.ExportedType.Resolve()
   ...

Log 'cut short' as it just repeats until it closes the console window, also of note, the stack overflow does not get logged to file so I copied from the console window directly

(From RML issue made on this, includes full console output on linux)
https://github.com/user-attachments/files/17197215/resoniteheadless_stackoverflow.log

Additional Context

Connected issue on RML https://github.com/resonite-modding-group/ResoniteModLoader/issues/16

Reporters

_deltawolf, nepushiro, rucio, adamski2003

XDelta commented 1 month ago

Tested a few assorted things including down to a plugin with basically no code in it beyond just [assembly: DataModelAssembly(DataModelAssemblyType.Core)] and it results in the same.

ProbablePrime commented 1 month ago

We still need a full log file,However I found one in: https://github.com/resonite-modding-group/ResoniteModLoader/issues/16 which allows me to see the bottom and top of the stack trace.

  at Mono.Cecil.TypeReference.Resolve()
   at FrooxEngine.Weaver.AssemblyPostProcessor.Process(System.String, System.String ByRef, System.String)
   at FrooxEngine.Weaver.AssemblyPostProcessor.Process(System.String, System.String)
   at FrooxEngine.Engine+<ProcessStartupCommands>d__324.MoveNext()

Tells me what's up and I can take a deeper look.

ProbablePrime commented 1 month ago

Tested a few assorted things including down to a plugin with basically no code in it beyond just [assembly: DataModelAssembly(DataModelAssemblyType.Core)] and it results in the same.

Can you make this available to me?

XDelta commented 1 month ago

The log included at the top was the 'full log' in terms of what is logged to file and has some of the output from a console window before it closes.

Sent barebones plugin via discord, also zipped up the same here ExamplePlugin.zip

ProbablePrime commented 1 month ago

Ok dug into this.

This is basically what we do with plugins:


                foreach (var assembly in options.AdditionalAssemblies)
                {
                    // run the processing on it
                    if (AssemblyPostProcessor.Process(assembly, frooxEnginePath))
                        UniLog.Log("POSTX Processed Assembly: " + assembly);
                }

So I took that to a new project, with @XDelta's test plugin:

static void Main(string[] args)
{
    var a = AssemblyPostProcessor.Process("ExamplePlugin.dll",null);
    Console.WriteLine(a);
}

This passes and is processed correctly, using fresh dlls from a build on my machine.

My next test will do the same but using the DLLs from the downloaded headless copy.

ProbablePrime commented 1 month ago

I tried it with the headless dlls and also could not reproduce outside of Resonite.

@Frooxius I'm stumped now, will need your help.

bontebok commented 1 month ago

I tried it with the headless dlls and also could not reproduce outside of Resonite.

Were you able to reproduce it? Just want to be sure that's what you're saying.

Also in regards to log, the Resonite log itself was not attached because it ends before collecting any details of the crash, I grabbed the Docker console output and provided that the RML issue I posted. The logs entries up until the crash are effectively the same.

ProbablePrime commented 1 month ago

I was unable to cause the crash, when using my test app.

As my test app is very simple, others could try the same as I with their files, perhaps that might show something. If you make a new .net project reference FrooxEngine.Weaver.dll from the build.

You'll also need to put FrooxEngine.dll in the bin folder of your test project.

Frooxius commented 1 month ago

I managed to reproduce this with the ExamplePlugin.dll on my end. I'll try to dig into why is it happening now.

Frooxius commented 1 month ago

Hmm, something must've messed up with the headless build, like a wrong or extra file copied. I did a clean rebuild and it works now.

I've pushed a headless update 2024.10.1.701. It's the same build as normal, just a clean rebuild.

Thanks for the report!