javisar / ONI-Modloader

A modloader for Oxygen Not Included
MIT License
72 stars 25 forks source link

StackOverflowException 4.0 #9

Closed L-a-n-g-o-l-i-e-r-s closed 6 years ago

L-a-n-g-o-l-i-e-r-s commented 6 years ago

Process is terminated due to StackOverflowException.

Mod.log is just full of "Reading modules" entries. This is on cosmic, new install of the game. Happens with or without mods in the mod folder.

Appreciate your time.

javisar commented 6 years ago

What OS are you using? Could you post Mod_Log.txt file, clean just with one execution of the injector? Also the console output if it is different. Try this "Injector.exe" (just that file) and let me know if it works. https://github.com/javisar/ONI-Modloader/releases/download/v0.1/v0.1.zip

L-a-n-g-o-l-i-e-r-s commented 6 years ago

After running Injector.exe from version 4.0 Mod_Log.txt is filled with 10,595 identical lines of "Reading modules: " with the error message "Process is terminated due to StackOverflowException." displayed in the console window. (Not the log.)

Running v0.1 injector after overwriting the old one and executing it didn't crash and it said it patched, there was no Mod_Log.txt and the game wouldn't work. The problem with 4.0 is it won't even patch, the first thing it says is the StackOverflowException. All previous versions worked fine.

Thanks.


System Information

     Operating System: Windows 10 Enterprise 2016 LTSB 64-bit (10.0, Build 14393) (14393.rs1_release_1.180427-1811)
             Language: English (Regional Setting: English)
            Processor: AMD Phenom(tm) II X4 830 Processor (4 CPUs), ~2.8GHz
               Memory: 8192MB RAM
  Available OS Memory: 8192MB RAM

|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

javisar commented 6 years ago

Sorry, but I cannot replicate the bug. I've added more logs to the injector to try to pinpoint the issue. Try this new version and paste the Mod_Log.txt file:

https://github.com/javisar/ONI-Modloader/blob/master/Managed/Injector.exe

L-a-n-g-o-l-i-e-r-s commented 6 years ago

I reinstalled ONI comet preview, I put the 4.0 files in the managed folder, then I overwrote injector.exe with the version you linked me here most recently, it still fails with the same message. It did actually close the console window when I closed the windows error reporting dialogue.

The log is the same as last time 10613 repeating lines of "Reading modules:

Reading modules: "

The older 3.0 version works on the regular build, not beta comet build. In fact, if I just separate the file on its own and launch it (secluded unrelated folder structure) 4.0 throws the exact same error.

Thanks

javisar commented 6 years ago

I really don't know what's the problem :( Some ideas:

Check if you have read only folders/files, you are running it as Administrator or there is something like Windows UAC active. Check if you have in the same folder 'Mono.Cecil.dll' Check if you have .NET 3.5 installed. The path to the game could be too long?

It's really weird that you get "Reading modules" so many times because there is no loop in the source code.

Maybe someone able to debug with VStudio has the same problem and can fix it.

L-a-n-g-o-l-i-e-r-s commented 6 years ago

I have .NET 3.5 installed, UAC is enabled but it has always been enabled. (Running it in admin mode makes no difference.) The file is present as it has been with every one of your installation packages. All of the prior versions wouldn't have worked and continue to at least open rather than open and immediately say "Process is terminated due to StackOverflowException." in the window. If I go back to the non-commet build of the game and the mod package (0.3.3), the injector patches fine.

Killface needs to open up issue tickets on his fork, he might know since he patched it, right?

Thanks

L-a-n-g-o-l-i-e-r-s commented 6 years ago

I did some checking, apparently the problem is related to a registry setting for some sort of debug to force dotnet applications to use the newest version.

Not sure why it was on, maybe when I installed VS I checked something in the installer, dunno. Mystery solved.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft.NETFramework] "OnlyUseLatestCLR"=dword:00000001 <- change 1 to 0.

Now if we could fix whatever mods are causing problems with the most recent update. Anyway thanks for your time and hard work.

javisar commented 6 years ago

Thank you @L-a-n-g-o-l-i-e-r-s for finding the problem. I've been able to replicate the bug 100%. Registry entry (I didn't have it) and also that debug .exe works fine. I'm going to keep open this issue because at some point we could find a solution that does not imply to mess with windows registry.

L-a-n-g-o-l-i-e-r-s commented 6 years ago

@javisar

This registry entry doesn't exist by default, When the registry entry does not exist, the system reads it the same as it would if it existed and was toggled off with "dword:00000000" setting.

When "dword:00000001" it forces .net applications to use the newest version of .net. (For whatever reason 0.4.0 of the injector is no longer compatible when forced to run with say .net 4.7.2. by this setting (unintentionally/unknown to me) meaning that it is now 100% dependent on .net 3.5 or whatever is listed in the requirements on the readme as it should be, previous versions ran fine, this is why I didn't notice the issue, not the injectors fault.)

Not a big deal, very unlikely anyone else will have this problem, if they do, they can simply put the following in a text file and rename the file extension to .reg and execute it:

"Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft.NETFramework] "OnlyUseLatestCLR"=dword:00000000"

(The 0 setting is the same as the registry entry having never existed in the first place, so making the entry in the first place isn't necessary if you aren't experiencing the problem, nothing wrong with the injector, so the average user won't need to do anything to the registry.)

javisar commented 6 years ago

I think I've found a way to solve it. I've deactivated "Optimize Code" in the file Injector.csproj in Visual Studio. This seems to make the trick.