MelonLoader

MelonLoader

242 Downloads

[Bug]: Game crashes without any log entry

startrekfleetcommand-dev opened this issue · 12 comments

commented

Latest.log

All of the following criteria must be met

  • All Requirements must be installed.
  • Changed the title so that it doesn't just says "[Bug]: "
  • I have searched the GitHub issues for my bug, even in the closed issues.

All of the following are optional to answer

  • Tried reinstalling the Game.
  • Tried reinstalling MelonLoader.
  • Tried restarting PC.
  • Was able to see the Start Screen.

Describe the issue.

With 0.6.5 on Windows 11, the game gets to a loading screen but consistently crashes silently, even when no mods or plugins are installed. With the example plugin it shows that OnInitializeMelon fires, but nothing after (OnGUI, OnUpdate etc.) No errors in Latest-Bootstrap.log either. Tried with AVG off, and in safe mode. Latest nightly as well, same thing.

https://startrekfleetcommand.com/download-game/

Event Viewer shows exception code 0xc0000005 in GameAssembly.dll , which Microsoft's Debug Diagnostic Tool describes as an access violation.

Had to move off of the rock solid 0.6.3 as it (and all versions before it) have Il2CppAssemblyGenerator throwing the following:

Cpp2IL.Core.Exceptions.LibCpp2ILInitializationException: Fatal Exception initializing LibCpp2IL! ---> System.FormatException: Unsupported metadata version found! We support 23-29, got 31

Weirdly the latest bepinex 6 can load into the game with the sample mod without errors, but it lacks the OnGui and OnUpdate functionality.

Did you attach your log file?

Yes, I attached my log file to the text box above.

commented

This does actually. Thank you!
I think I have an idea that might resolve the issue but we are still working on it.
I will notify you once its ready to be tested.

commented

Give the latest alpha-development build of v0.6.6 a try and let me know if you have the same problem.
https://nightly.link/LavaGang/MelonLoader/workflows/build/alpha-development

commented

Latest.log

Thanks for responding! Tried both x64 Release and Debug there, in clean installs, and they fail in the same spot. Same 0xc0000005 in GameAssembly.dll . Anything else I could try?

commented

Redownload the alpha-development build of v0.6.6 from the same URL and try again.
We have just made more changes that might help more.
https://nightly.link/LavaGang/MelonLoader/workflows/build/alpha-development/MelonLoader.Windows.x64.CI.Debug.zip

commented

Thanks for staying on this! Same issue in a clean install with no mods unfortunately - 0xc0000005 in GameAssembly.dll . I've highlighted the changes to the most recent Debug.log using Beyond Compare (Latest-Bootstrap.log is the same)

Latest.log

[MonoLibrary] Caught SecurityException, assuming not running under mono and continuing with init
to
[MelonAssemblyResolver] Setup Successful!
Loading MelonModule 'C:\Games\Star Trek Fleet Command\default\game\MelonLoader\Dependencies\CompatibilityLayers\EOS.dll'
to
*removed*
[DotnetManagedFolder] Loading from C:\Games\Star Trek Fleet Command\default\game\MelonLoader\Il2CppAssemblies\Il2Cppmscorlib.dll...
[DotnetManagedFolder] Loading from C:\Games\Star Trek Fleet Command\default\game\MelonLoader\Il2CppAssemblies\UnityEngine.CoreModule.dll...
to
[MelonAssemblyResolver] Loading from C:\Games\Star Trek Fleet Command\default\game_MelonLoader_0.6.6_AlphaB\MelonLoader\Il2CppAssemblies\Il2Cppmscorlib.dll...
[MelonAssemblyResolver] Loading from C:\Games\Star Trek Fleet Command\default\game_MelonLoader_0.6.6_AlphaB\MelonLoader\Il2CppAssemblies\UnityEngine.CoreModule.dll...

Please keep looking, and I'll keep trying!

commented

Been wondering if its something in the binaries of the latest game update causing the crash, aka attempts to block external loaders/libraries etc, so found a pre-update copy of the game with 0.6.2 installed. It still runs without crashing, and stops with the expected "You need to update your game" screen (process stays executing, my mod loads great, no appcrash or uncaught exception).

Keeping the pre-update copy of the game, removing the 0.6.2 Melonloader folder and emptying the Mods and UserLibs folders, and then installing 0.6.4, 0.6.5 and latest alpha 0.6.6 all yield the 0xc0000005 appcrash in the GameAssembly.dll

I mentioned "the rock solid 0.6.3" in my initial post. I meant to say 0.6.2 was rock solid. In the above scenario 0.6.3 fails early with the following (typed out from a screenshot, not present in Latest.log):

[NewEntryPoint] Passing ptr to LoadAssemblyAndGetFunctPtr back to host...
[NewEntryPoint] Configuring imports...
[NewEntryPoint] Initializing. In default load context: True
[!] [C:\Users\Sam\CLionProjects\Dobby\source\InstructionRelocation\x64\X64InstructionRelocation.cc:86:GenRelocateCodeFixed]:
[!] unimplemented code!!!

I really hope this helps nail down when the issue could have crept in.

commented

@startrekfleetcommand-dev Can you try my temp fix in #780 ?

commented

@HerpDerpinstine Possible issue and temp fix is in: #780

commented

Hi Lillious, thanks for checking in with my issue. I definitely tried all variations of command line parameters early on. I even downloaded and built the MelonLoader source to determine the exact line of code that was failing, but I'm guessing its related to a method patch gone awry. I'm not very familiar with this concept, so not sure how to trace it.

On a related note @HerpDerpinstine, while Bepinex 6 loads successfully with no mods enabled, and also with the basic mod enabled (that simply prints on various callbacks), it fails the exact same way when trying to read an external file (0xc0000005 appcrash in the GameAssembly.dll, with nothing written to log, and the only indication is in Event Viewer).

I know its not necessarily related to what's happening in MelonLoader with no mods installed, but its interesting that they both crash the same way. It suggests to me that there's an issue, potentially with both tools, in running certain external functions.

I'll be posting this issue in their wiki, but here's what it looks like:

Works (prints the line and the game loads):

public override void Load()
{
    base.Log.LogInfo($"Plugin {MyPluginInfo.PLUGIN_GUID} is loaded!");
}

Prints both correctly (even if the file is zero or one bytes), but crashes silently as described above:

public override void Load()
{
    base.Log.LogInfo($"Plugin {MyPluginInfo.PLUGIN_GUID} is loaded!");
    string txt = System.IO.File.ReadAllText("text.txt"); 
    base.Log.LogInfo("Read bytes: " + txt.Length);
}
commented

hello @HerpDerpinstine
I had the same issue with Vampire survivors throwing Unsupported metadata version found! We support 23-29, got 31
trying multiple versions including downgrading to the ones that worked in the past,
rebooting reinstalling etc

I tried the version you suggested https://nightly.link/LavaGang/MelonLoader/workflows/build/alpha-development/MelonLoader.Windows.x64.CI.Debug.zip

this has fixed the issue for me

however, it's worth noting that my AV flagged il2CppZenject.dll and moved it to quarantine, wondering if AV is causing issues for other users without them noticing. as I never noticed this being flagged in the past but I may have missed it.

commented

I also had AVG issues Ceph (all false positives hopefully) - I have done my testing with AVG enabled (and creating exceptions) and disabled so I'm pretty sure its not the cause if my issue.

While I had no problems getting the game to boot with the latest Bepinex 6, it would crash for certain operations with my mod (reading or writing some files) or randomly after differing periods of time (whether sitting idle, or in active use). I therefore tried copying the output of Il2CppAssemblyGenerator from Bepinex (folder Bepinex\interop) to MelonLoader 0.6.2 (folder MelonLoader\Managed) and was able to boot the game, even with my mod enabled.

This required that I prevent the MelonLoader assembly generation (which cannot read version 31 metadata) by adding the correct GameAssemblyHash and OldFiles entries in MelonLoader\Dependencies\Il2CppAssemblyGenerator\Config.cfg , and updating MelonLoader\Dependencies\SupportModules\Il2CppInterop.Runtime.dll from 1.4.5 to 1.4.6

I was very pleased to see the game running under the older MelonLoader, but it unfortunately has the same issue as when running in Bepinex 6. It would randomly crash with my mod, whether after 3 minutes of gameplay or 30, idle or in use. Even with extraneous libraries and all file I/O removed.

Not sure where to go next, other than try other loaders and frankenstein what works :-)

I'll keep checking back!

PS - I attached dnSpyEx to the running process, and had it break on all thrown exceptions (to see if I could catch the unhandled exception that was causing the crash). While it did catch a large number of System.BadImageFormatExceptions (Read out of bounds) in System.Reflection.Metadata , these were handled and none immediately preceded the crash. The only indication dnSpyEx's output gave was "The program '[0x4A90] prime.exe' has exited with code 0 (0x0)."

commented

I noticed this issue on a game called "Who's Your Daddy?!" on Steam. The Classic version (not the Remake) uses Unity 2017, and any modern ML past v0.4.? will just simply crash on startup. It popups up with a terminal window, then flashes an error then quickly closes. I managed to see the words "System.Drawing" once or something like that.

The Classic version is an x64 Mono game. (Remake is x64 IL2CPP, made with Unity 2020 iirc, and that works fine)

It's a shame modern ML doesn't work on older Unity versions :(