`launch.sh` Script Improperly Handles Java Parameters from Config
erin-allison opened this issue ยท 0 comments
Modpack version
dev
Description
In launch.sh
, when the configuration is parsed and Java is being executed, the entirety of the JAVA_PARAMETERS
is passed as a single quoted value. This seems to be handled internally by Java, but fails in certain cases.
The entire string being passed as one value seems to be due to IFS
getting set to a newline, instead of a space, which changes the shell's semantics for string processing.
Below is additional info that details why this is an issue:
If you define multiple parameters in launch_config.ini
and the first listed parameter begins with -XX:...
, the JVM will not launch, returning an error such as below:
> /usr/lib/jvm/java-8-openjdk/jre/bin/java -server -Xms8192M -Xmx12288M -XX:G1HeapRegionSize=32M -Dsun.rmi.dgc.server.gcInterval=2147483646 -XX:+UseG1GC -XX:+UnlockExperimentalVMOptions -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -jar forge-1.12.2-14.23.5.2860.jar nogui
Improperly specified VM option 'G1HeapRegionSize=32M -Dsun.rmi.dgc.server.gcInterval=2147483646 -XX:+UseG1GC -XX:+UnlockExperimentalVMOptions -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
If I instead move the option -XX:G1HeapRegionSize=32M
to the end of the parameters string, the server will launch without issue
> /usr/lib/jvm/java-8-openjdk/jre/bin/java -server -Xms8192M -Xmx12288M -Dsun.rmi.dgc.server.gcInterval=2147483646 -XX:+UseG1GC -XX:+UnlockExperimentalVMOptions -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M -jar forge-1.12.2-14.23.5.2860.jar nogui
[16:02:54] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLServerTweaker
[16:02:54] [main/INFO] [LaunchWrapper]: Using primary tweak class name net.minecraftforge.fml.common.launcher.FMLServerTweaker
This can be reproduced with as few as two options, such as the two that ship as defaults in launch_config.ini
:
In the order defined in the repository, the server launches without issue, but if reversed, the same error is presented.
Note that in all of the above cases, I can copy/paste the exact command line echoed out by the script and launch the server manually with no issues.
Steps to reproduce
- Download server zip on Linux
- Reverse order of Java Parameters in
launch_config.ini
- Attempt to launch server using
launch.sh
Expected behavior
The server should launch properly, regardless of option ordering in the config.
In order to address this behavior, IFS should be set back to a single space prior to launching Java.
Additional context
See conversation starting here: https://discord.com/channels/691927762755387402/691936422969606204/1297277435737276417
Your Divine Journey 2 Discord Username
No response