MelonLoader

MelonLoader

554 Downloads

[Bug]: SceneManager load/unload event overrides cause DivideByZero and TargetInvokation Exceptions respectively

KaySteinhoff opened this issue ยท 0 comments

commented

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.

Upon loading the SceneHandler throws a DivideByZeroException when trying to override the sceneLoaded event.
Similarly when overriding the sceneUnload event a TargetInvocationException is thrown.

This may be caused by Il2Cpp.dll being loaded after this point, although I have not read to deep into the source code and this is just my guess.

The exceptions are thrown by the stable release(0.7.1) as well as the nightly build(0.7.2-ci.2331).
No mods loaded.

Here's the log file:

[08:40:19.871] ------------------------------
[08:40:19.873] MelonLoader v0.7.2-ci.2331 Open-Beta
[08:40:19.874] OS: Wine/Proton 10.0
[08:40:19.875] Hash Code: A5E213F56BDE4361F1071F4989EFC57F6320F0580A651615FC9C27C86D795953
[08:40:19.876] ------------------------------
[08:40:19.877] Game Type: Il2cpp
[08:40:19.878] Game Arch: x64
[08:40:19.879] ------------------------------
[08:40:19.880] Command-Line: 
[08:40:19.881] ------------------------------
[08:40:19.882] Core::BasePath = Z:\run\media\kay\8TB Space\SteamLibrary\steamapps\common\Underspace
[08:40:19.886] Game::BasePath = Z:\run\media\kay\8TB Space\SteamLibrary\steamapps\common\Underspace
[08:40:19.887] Game::DataPath = Z:\run\media\kay\8TB Space\SteamLibrary\steamapps\common\Underspace\Underspace_Data
[08:40:19.888] Game::ApplicationPath = Z:\run\media\kay\8TB Space\SteamLibrary\steamapps\common\Underspace\Underspace.exe
[08:40:19.888] Runtime Type: net6
[08:40:20.061] ------------------------------
[08:40:20.062] Game Name: Underspace
[08:40:20.063] Game Developer: Pastaspace Interactive
[08:40:20.065] Unity Version: 2018.2.21f1
[08:40:20.066] Game Version: 1.0
[08:40:20.067] ------------------------------

[08:40:20.466] Preferences Loaded!

[08:40:21.523] Loading UserLibs...
[08:40:21.526] 0 UserLibs loaded.

[08:40:21.527] Loading Plugins...
[08:40:21.532] 0 Plugins loaded.

[08:40:22.683] Loading Il2CppAssemblyGenerator...
[08:40:22.730] [Il2CppAssemblyGenerator] Contacting RemoteAPI...
[08:40:22.953] [Il2CppAssemblyGenerator] Game Not Found on RemoteAPI Host (https://api.melonloader.com/api/v1/game/underspace)
[08:40:22.954] [Il2CppAssemblyGenerator] RemoteAPI.DumperVersion = null
[08:40:22.955] [Il2CppAssemblyGenerator] RemoteAPI.ObfuscationRegex = null
[08:40:22.957] [Il2CppAssemblyGenerator] RemoteAPI.MappingURL = null
[08:40:22.958] [Il2CppAssemblyGenerator] RemoteAPI.MappingFileSHA512 = null
[08:40:22.963] [Il2CppAssemblyGenerator] Using Cpp2IL Version: 2022.1.0-pre-release.20
[08:40:22.964] [Il2CppAssemblyGenerator] Using Il2CppInterop Version = 1.5.1+dbaf825aab891ff1e1627bea691bde0a81d1ad98
[08:40:22.965] [Il2CppAssemblyGenerator] Using Unity Dependencies Version = 2018.2.21
[08:40:22.967] [Il2CppAssemblyGenerator] Using Deobfuscation Regex = null
[08:40:22.968] [Il2CppAssemblyGenerator] Cpp2IL is up to date.
[08:40:22.969] [Il2CppAssemblyGenerator] Cpp2IL.Plugin.StrippedCodeRegSupport is up to date.
[08:40:22.971] [Il2CppAssemblyGenerator] UnityDependencies is up to date.
[08:40:22.972] [Il2CppAssemblyGenerator] Checking GameAssembly...
[08:40:23.105] [Il2CppAssemblyGenerator] Assembly is up to date. No Generation Needed.

[08:40:23.107] Loading Mods...
[08:40:23.108] 0 Mods loaded.

[08:40:24.991] [Il2CppInterop] Class::Init signatures have been exhausted, using a substitute!
[08:40:25.138] [Il2CppInterop] Registered mono type Il2CppInterop.Runtime.DelegateSupport+Il2CppToMonoDelegateReference in il2cpp domain
[08:40:25.144] SceneManager.sceneLoaded override failed: System.DivideByZeroException: Attempted to divide by zero.
   at Il2CppInterop.Runtime.Injection.Hooks.GenericMethod_GetMethod_Hook.Hook(Il2CppGenericMethod* gmethod, Boolean copyMethodPtr) in /home/runner/work/Il2CppInterop/Il2CppInterop/Il2CppInterop.Runtime/Injection/Hooks/GenericMethod_GetMethod_Hook.cs:line 33
   at Il2CppInterop.Runtime.IL2CPP.il2cpp_object_get_virtual_method(IntPtr obj, IntPtr method)
   at Il2CppSystem.Reflection.MethodBase.GetParameters()
   at Il2CppInterop.Runtime.DelegateSupport.ConvertDelegate[TIl2Cpp](Delegate delegate) in /home/runner/work/Il2CppInterop/Il2CppInterop/Il2CppInterop.Runtime/DelegateSupport.cs:line 249
   at UnityEngine.Events.UnityAction`2.op_Implicit(Action`2 )
   at MelonLoader.Support.SceneHandler.Init() in D:\a\MelonLoader\MelonLoader\Dependencies\SupportModules\SceneHandler.cs:line 28
[08:40:25.145] SceneManager.sceneUnloaded override failed: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.TypeInitializationException: The type initializer for 'Il2CppInterop.Runtime.Il2CppClassPointerStore`1' threw an exception.
 ---> System.TypeInitializationException: The type initializer for 'UnityEngine.Events.UnityAction`1' threw an exception.
 ---> System.DivideByZeroException: Attempted to divide by zero.
   --- End of inner exception stack trace ---
   at System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(RuntimeTypeHandle type)
   at Il2CppInterop.Runtime.Il2CppClassPointerStore`1..cctor() in /home/runner/work/Il2CppInterop/Il2CppInterop/Il2CppInterop.Runtime/Il2CppClassPointerStore.cs:line 42
   --- End of inner exception stack trace ---
   --- End of inner exception stack trace ---
   at System.RuntimeFieldHandle.GetValue(RtFieldInfo field, Object instance, RuntimeType fieldType, RuntimeType declaringType, Boolean& domainInitialized)
   at System.Reflection.RtFieldInfo.GetValue(Object obj)
   at Il2CppInterop.Runtime.Il2CppClassPointerStore.GetNativeClassPointer(Type type) in /home/runner/work/Il2CppInterop/Il2CppInterop/Il2CppInterop.Runtime/Il2CppClassPointerStore.cs:line 17
   at Il2CppInterop.Runtime.DelegateSupport.ConvertDelegate[TIl2Cpp](Delegate delegate) in /home/runner/work/Il2CppInterop/Il2CppInterop/Il2CppInterop.Runtime/DelegateSupport.cs:line 227
   at UnityEngine.Events.UnityAction`1.op_Implicit(Action`1 )
   at MelonLoader.Support.SceneHandler.Init() in D:\a\MelonLoader\MelonLoader\Dependencies\SupportModules\SceneHandler.cs:line 42
[08:40:25.159] [Il2CppInterop] Registered mono type MelonLoader.Support.MonoEnumeratorWrapper in il2cpp domain
[08:40:25.165] [Il2CppInterop] Registered mono type MelonLoader.Support.SM_Component in il2cpp domain
[08:40:25.173] Support Module Loaded: Z:\run\media\kay\8TB Space\SteamLibrary\steamapps\common\Underspace\MelonLoader\Dependencies\SupportModules\Il2Cpp.dll

Did you attach your log file?

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