-
Notifications
You must be signed in to change notification settings - Fork 1.8k
VectorizeSIMD breaks Minecraft under specific conditions. #4849
Description
Describe the issue
GraalVM EE's VectorizeSIMD optimization crashes Minecraft or breaks rendering under specific circumstances. Disabling the VectorizeSIMD flag fixes the issue, as does disabling compilation of specific methods, like net.minecraft.class_4604.method_23092
More details
I first ran into this issue with the Sodium and Iris mods in a "default" GraalVM EE environment. After playing for a minute or so, all entities turn invisible (notice their shadows on the ground):
Disabling VectorizeSIMD or the compilation of net.minecraft.class_4604.method_23092 fixes this issue.
At first, I thought this was an issue specific to those modifications, but as I started forcing compilation with very low CompileThresholdScaling values or -Xcomp and narrowing down the issue to a more specific chain of methods, I discovered the affected methods were base Minecraft methods, and this bug started manifesting itself without the Iris modification. Specifically, with just the "Sodium" and "Fabric" Minecraft modifications, all entities turn invisible, as in the above screenshot. With just the "Fabric" modding API, and the specific graal arguments from below, the whole application hangs on the frame entities turn invisible:
-XX:+UnlockExperimentalVMOptions -XX:+UnlockDiagnosticVMOptions -Dgraal.UsePriorityInlining=false -Dgraal.VectorizeSIMD=true -Dgraal.PrintCompilation=true -XX:CompileThresholdScaling=0.05 -Xcomp -XX:JVMCIThreads=1 -XX:-UseDynamicNumberOfCompilerThreads -Dgraal.LogFile=fabriccrash.log -Dgraal.TraceBytecodeParserLevel=0 -Dgraal.GraalCompileOnly=net.minecraft.class_1159.method_22672,net.minecraft.class_1159.method_22673,net.minecraft.class_1159.method_22871,net.minecraft.class_1162.<init>,net.minecraft.class_1162.method_22674,net.minecraft.class_4604.<init>,net.minecraft.class_4604.handler*,net.minecraft.class_4604.method_23088,net.minecraft.class_4604.method_23091,net.minecraft.class_4604.method_23092,java.lang.Object.<init>,net.minecraft.class_1159.<init>
net/Minecraft/class_4604.method_23092 (which is documented in the below link) seems to be the final and exact compilation that breaks or crashes rendering (as it is the final compiled method in the attached logs), but this bug will not manifest itself without the other specified compiled methods.
A side note: Minecraft classes/methods are obfuscated, and they show up as jibberish in the graal compilation log. But modding APIs (such as Fabric, which I was testing with) map, name and document these obfuscated classes so modders can use them, as you can see in the documentation here
This is relevant because the methods I narrowed this issue down to with Dgraal.CompileOnly use the Fabric method/class names... but this bug also manifests itself in environments without the "Fabric" mod (such as Forge), so it cannot be a "Fabric" mod bug. Hence I am fairly certain it could manifest in the base game as well, without any mods. But this is difficult to test, as I would have to "reverse map" these methods to the base game in order for the Graal compilation filter to recognize them.
Cross-platform steps to reproduce the issue
- Install the "PolyMC" Minecraft launcher. It is available on Github, or in some repos (like the AUR): https://github.com/PolyMC/PolyMC
- Import the following instance into it: Iris-Sodium.zip
- Run the Minecraft client instance with the specified GraalVM flags.
- Create a new "superflat" world for testing. If the game doesn't crash upon loading, all entities (like monsters and villagers) will be invisible.
- Disable
VectorizeSIMD, and the issue will not persist.
Describe GraalVM and your environment:
- GraalVM version: EE 22.2.0
- JDK major version: 17
- OS: Windows 10
- Architecture: AMD64
Logs + Dumps
Invisible entities: sodiumwithsimd.zip
Same setup with VectorizeSIMD disabled: sodiumwithoutsimd.zip
Crash upon loading world with the "Fabric" API: fabrichangwithsimd.zip
Same setup with VectorizeSIMD disabled: fabricwthoutsimd.zip
Let me know if I can provide any more information for debugging.
