MinecraftForge / MinecraftForge

Modifications to the Minecraft base files to assist in compatibility between mods. New Discord: https://discord.minecraftforge.net/
https://files.minecraftforge.net/
Other
6.77k stars 2.65k forks source link

Mod discovery fails if empty JAR on classpath #8587

Closed Jtrim777 closed 2 years ago

Jtrim777 commented 2 years ago

Minecraft Version: 1.18.1

Forge Version: 39.0.5

Logs: Log up until hang

Steps to Reproduce:

  1. Have an empty JAR file (i.e. only a MANIFEST) on the classpath used by runClient
  2. Run ./gradlew runClient
  3. Process will hang after "Found supplied mod coordinates"

Description of issue: Took a while to generate a stack trace since it doesn't actually crash, but at:

cpw.mods.jarhandling.impl.Jar::new (Jar.java:92)
at cpw.mods.jarhandling.SecureJar.from (SecureJar.java:57)
at net.minecraftforge.fml.loading.moddiscovery.AbstractJarFileLocator.createMod (AbstractJarFileLocator.java:81)
at net.minecraftforge.fml.loading.moddiscovery.AbstractJarFileLocator.scanMods (AbstractJarFileLocator.java:66)
at net.minecraftforge.fml.loading.moddiscovery.ModDiscoverer.discoverMods (ModDiscoverer.java:64)
at net.minecraftforge.fml.loading.FMLLoader.beginModScan (FMLLoader.java:180)
...

there's a while loop

while (SecureJarVerifier.isParsingMeta(jv)) {
    jis.getNextJarEntry();
}

It appears that when there are no entries in the JAR besides the MANIFEST.MF file, jis.getNextJarEntry(); has no effect, and thus SecureJarVerifier.isParsingMeta(jv) always returns true, leading to an infinite loop. This occurs when the Classpath locator is being called on by ModDiscoverer, and it finds an empty JAR in the classpath (in my case downloaded by one of my dependencies). Freezing the loading process, deleting that JAR, and then releasing it causes the game to spin up just fine.

sciwhiz12 commented 2 years ago

Root issue in the relevant project repository is McModLauncher/securejarhandler#15, which was fixed by McModLauncher/securejarhandler#16, first published in securejarhandler 1.0.1, which the dependency in Forge was bumped to such version by https://github.com/MinecraftForge/MinecraftForge/commit/00fafb07cee8aea39e09a4e8189c2fefcbed9eca, published as 39.0.44.

Closing due to outdated Forge installation, as latest 1.18.1 already contains the updated dependenciy with the fix.

Also, please note that our support of 1.18.x extends only to 1.18.2 currently -- older minor versions (such as 1.18 and 1.18.1) are unsupported and will never receive bugfixes once Forge moves to a newer minor version (such as 1.18.2).