LavaGang / MelonLoader

The World's First Universal Mod Loader for Unity Games compatible with both Il2Cpp and Mono
https://discord.gg/2Wn3N2P
Apache License 2.0
2.43k stars 476 forks source link

[Bug]: Il2CppAssemblyGenerator attempts to create an invalid directory and crashes #779

Open PavelDobCZ23 opened 13 hours ago

PavelDobCZ23 commented 13 hours ago

All of the following criteria must be met

All of the following are optional to answer

Describe the issue.

I am unable to start MelonLoader 0.6.5 with native Linux version of The Long Dark. The cause is Il2CppAssemblyGenerator attempting to create a directory with the name Cpp2IL in a directory where is Cpp2IL executable located and it fails. It shouldn't do that as it's impossible to have a directory and a file with the same name on Linux file systems, therefore this behavior needs to be changed. The issue can be found at the last few lines of the provided log.

Log:

[13:29:50.586] ------------------------------
[13:29:50.601] MelonLoader v0.6.5 Open-Beta
[13:29:50.601] OS: Unix 6.11.4.201
[13:29:50.601] Hash Code: ECEE59E98250B37FBAD36ACD622C0C177FB65E478F6B3EE58F58366B6557DF70
[13:29:50.601] ------------------------------
[13:29:50.601] Game Type: Il2cpp
[13:29:50.601] Game Arch: x64
[13:29:50.601] ------------------------------
[13:29:50.601] Command-Line: /home/pavel/.local/share/Steam/steamapps/common/TheLongDark/tld.x86_64
[13:29:50.602] ------------------------------
[13:29:50.602] Core::BasePath = /home/pavel/.local/share/Steam/steamapps/common/TheLongDark
[13:29:50.602] Game::BasePath = /home/pavel/.local/share/Steam/steamapps/common/TheLongDark
[13:29:50.602] Game::DataPath = /home/pavel/.local/share/Steam/steamapps/common/TheLongDark/tld_Data
[13:29:50.602] Game::ApplicationPath = /home/pavel/.local/share/Steam/steamapps/common/TheLongDark/tld.x86_64
[13:29:50.602] Runtime Type: net6
[13:29:50.663] ------------------------------
[13:29:50.663] Game Name: TheLongDark
[13:29:50.663] Game Developer: Hinterland
[13:29:50.664] Unity Version: 2021.3.16f1
[13:29:50.664] Game Version: 2.32
[13:29:50.664] ------------------------------

[13:29:51.114] [Il2CppICallInjector] System.Exception: Unable to Load Native Library GameAssembly!
   at MelonLoader.NativeLibrary.LoadLib(String filepath) in D:\a\MelonLoader\MelonLoader\MelonLoader\Utils\NativeLibrary.cs:line 29
   at MelonLoader.NativeLibrary.Load(String filepath) in D:\a\MelonLoader\MelonLoader\MelonLoader\Utils\NativeLibrary.cs:line 18
   at MelonLoader.Fixes.Il2CppICallInjector.Install() in D:\a\MelonLoader\MelonLoader\MelonLoader\Fixes\Il2CppICallInjector.cs:line 85
[13:29:51.147] Preferences Loaded!

[13:29:51.156] Loading UserLibs from '/home/pavel/.local/share/Steam/steamapps/common/TheLongDark/UserLibs'...

[13:29:51.161] Loading Plugins from '/home/pavel/.local/share/Steam/steamapps/common/TheLongDark/Plugins'...
[13:29:51.162] 0 Plugins loaded.
[13:29:53.361] Loading Il2CppAssemblyGenerator...
[13:29:53.386] [Il2CppAssemblyGenerator] Contacting RemoteAPI...
[13:29:53.525] [Il2CppAssemblyGenerator] RemoteAPI.DumperVersion = null
[13:29:53.525] [Il2CppAssemblyGenerator] RemoteAPI.ObfuscationRegex = null
[13:29:53.525] [Il2CppAssemblyGenerator] RemoteAPI.MappingURL = null
[13:29:53.525] [Il2CppAssemblyGenerator] RemoteAPI.MappingFileSHA512 = null
[13:29:53.527] [Il2CppAssemblyGenerator] Using Cpp2IL Version: 2022.1.0-pre-release.18
[13:29:53.527] [Il2CppAssemblyGenerator] Using Il2CppInterop Version = 1.4.6-ci.545+3da49636029e18c88fe93901a893499a2d779805
[13:29:53.527] [Il2CppAssemblyGenerator] Using Unity Dependencies Version = 2021.3.16
[13:29:53.527] [Il2CppAssemblyGenerator] Using Deobfuscation Regex = null
[13:29:53.528] [Il2CppAssemblyGenerator] Cpp2IL is up to date.
[13:29:53.528] [Il2CppAssemblyGenerator] UnityDependencies is up to date.
[13:29:53.528] [Il2CppAssemblyGenerator] Checking GameAssembly...
[13:29:53.711] [Il2CppAssemblyGenerator] Assembly Generation Needed!
[13:29:53.716] [Il2CppAssemblyGenerator] Executing Cpp2IL...
[13:29:53.717] [Il2CppAssemblyGenerator] "/home/pavel/.local/share/Steam/steamapps/common/TheLongDark/MelonLoader/Dependencies/Il2CppAssemblyGenerator/Cpp2IL/Cpp2IL" --game-path "/home/pavel/.local/share/Steam/steamapps/common/TheLongDark" --exe-name "tld.x86_64" --output-as dummydll --use-processor attributeanalyzer attributeinjector
[13:29:53.720] TODO: SetProcessId(206774)
[13:29:53.737] [Il2CppAssemblyGenerator] Failure processing application bundle.
[13:29:53.737] [Il2CppAssemblyGenerator] Failed to create directory [/home/pavel/.local/share/Steam/steamapps/common/TheLongDark/MelonLoader/Dependencies/Il2CppAssemblyGenerator/Cpp2IL/Cpp2IL/] for extracting bundled files.
[13:29:53.739] TODO: SetProcessId(0)

Did you attach your log file?

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

SamboyCoding commented 13 hours ago

So, this isn't actually an issue with ML itself. This would appear to be an issue with .net single file executables (which Cpp2IL is) when running on Linux, where it tries to make a directory to unpack itself next to the executable. Which is unusual, because you'd think they'd have tested that.

PavelDobCZ23 commented 8 hours ago

So, this isn't actually an issue with ML itself. This would appear to be an issue with .net single file executables (which Cpp2IL is) when running on Linux, where it tries to make a directory to unpack itself next to the executable. Which is unusual, because you'd think they'd have tested that.

I don't know much about this to guess what's going on, but I believe the extraction should happen somewhere else completely, and it's dependent on DOTNET_BUNDLE_EXTRACT_BASE_DIR environment variable, which in my case is in .cache folder and Cpp2IL does actually extract something in there. It creates this dir /home/pavel/.cache/dotnet_bundle_extract/Cpp2IL/4w0CSh42PpXKsRT_O43nd2rL9zRY3QI=/, which contains a single file libcapstone.so. Idk if this info helps in any way, but I think it's relevant.