graal icon indicating copy to clipboard operation
graal copied to clipboard

Regression: UsePriorityInlining crashes Minecraft

Open brucethemoose opened this issue 2 years ago • 9 comments

Describe the issue GraalVM Enterprise Edition 22.2.0 for Java 17 crashes Minecraft 1.19.1 and 1.18.2. It may also crash older versions of Minecraft. This crash does not occur in GraalVM EE 22.1.0 or any older version of GraalVM EE, or on any other Java distribution.

Minecraft does not crash in GraalVM 22.2.0 with this flag: Dgraal.UsePriorityInlining=false

Steps to reproduce the issue I can't redistribute Minecraft, but I can make the reproduction as easy as possible for anyone with a license:

  • Download the open source polyMC launcher here, which makes selecting Java versions/flags easy: https://github.com/PolyMC/PolyMC
  • Create a vanilla 1.19.1 Minecraft instance
  • Select GraalVM as your Java distribution in the settings menu.
  • Launch Minecraft
  • Create a singleplayer world, and the game will crash.
  • Add the flag Dgraal.UsePriorityInlining=false
  • Create a singleplayer world. Minecraft will not crash.

Describe GraalVM and your environment:

  • GraalVM version EE 22.2.0
  • JDK major version: 17
  • OS: Windows 10 Home 21H2
  • Architecture: AMD64

More Details

A crashlog: https://mclo.gs/DRTHNnE

brucethemoose avatar Jul 31 '22 18:07 brucethemoose

@brucethemoose thanks, we will have a look.

davleopo avatar Aug 01 '22 08:08 davleopo

Link to the equivalent issue on Mojang's bug tracker: https://bugs.mojang.com/browse/MC-254802

brucethemoose avatar Aug 03 '22 13:08 brucethemoose

@brucethemoose Could you please try if more narrowed -Dgraal.SimulationBasedLoopPeeling=false option can be a workaround for the issue?

If yes then it could be a duplication of https://github.com/oracle/graal/issues/4773

plokhotnyuk avatar Aug 03 '22 13:08 plokhotnyuk

@brucethemoose Could you please try if more narrowed -Dgraal.SimulationBasedLoopPeeling=false option can be a workaround for the issue?

If yes then it could be a duplication of #4773

@plokhotnyuk Unfortunately, it still crashes/fails with Dgraal.SimulationBasedLoopPeeling=false

I like this line of thinking though. I will look for more narrow flags to test (and am open to suggestions).

brucethemoose avatar Aug 03 '22 14:08 brucethemoose

@brucethemoose @plokhotnyuk thanks for the suggestions I am on it, and can reproduce the issue locally on linux. Most of our optimization flags do not have any impact sadly, I am digging....

davleopo avatar Aug 03 '22 14:08 davleopo

@brucethemoose based on older bug reports for minecraft I know there is something like a seed for the world. For me locally it becomes more flaky when narrowing down compilation units and I wonder how I can set the world seed in the poly UI. Is that possible?

davleopo avatar Aug 09 '22 15:08 davleopo

@brucethemoose based on older bug reports for minecraft I know there is something like a seed for the world. For me locally it becomes more flaky when narrowing down compilation units and I wonder how I can set the world seed in the poly UI. Is that possible?

The seed is set in the client when you create a world in-game, in the options screen. I dont think any launcher can do it because they dont have any control over world creation.

But you can also set a world seed in the server.properties file for a dedicated minecraft server. If inlining crashes the server as well (and it may... I can check later today), thats definitely the easiest and most deterministic way to test.

brucethemoose avatar Aug 09 '22 16:08 brucethemoose

@davleopo I've confirmed the dedicated server crashes as well, here's a log: cmd.log

But I've made a interesting discovery. The Minecraft dedicated server, by default, launches a little window showing memory usage, connected players and such. Adding the nogui option prevents that window from spawning, and it also prevents the crash from happening:

nocrash.log

So the repro step is now this:

  • Download the Minecraft dedicated server jar, for free with no registration, here: https://www.minecraft.net/en-us/download/server
  • Run it with [path to graal] -Xmx1024M -Xms1024M -jar server.jar
  • Accept the eula in the generated file.
  • Add this file if you want a consistent world seed: server.properties.zip
  • Run it again. Minecraft will crash if running GraalVM 22.2.0
  • Now run [path to java] -Xmx1024M -Xms1024M -jar server.jar nogui
  • Minecraft will not crash.
  • It will also not crash with priorityinlining disabled, even with the gui enabled.

I'm noticing a pattern with GraalVM Minecraft bugs. All three I am aware of (and some unconfirmed ones I'm tracking down) are related to graphics/rendering... surely that's not a coincidence.

brucethemoose avatar Aug 10 '22 00:08 brucethemoose

@brucethemoose thanks for these hints that will help diagnosing it a lot. Roundtrip time went from 3 min to 10sec ;-)

davleopo avatar Aug 10 '22 08:08 davleopo

@brucethemoose thanks for all your efforts. We could identify the problem being a wrong virtualization in partial escape analysis. A fix will be in 22.3. As a workaround you can either disable -Dgraal.UsePriorityInlining=false or partial escape analysis itself with -Dgraal.PartialEscapeAnalysis=false.

davleopo avatar Aug 12 '22 07:08 davleopo

Excellent, thanks!

Disabling PartialEscapeAnalysis has a ~6% hit in a Minecraft chunkgen benchmark, but its still much better than disabling PriorityInlining: benchmark-2022-08-12_19-15-12.json.txt

...but on the other hand, Dgraal.PartialEscapeAnalysis=false seems to consistently shorten G1GC pauses? That's odd.

Anyway, I have an idea for how to fully automate testing Minecraft client graphical issues that may still exist in 22.3.0, but it will take some time to write/test.

brucethemoose avatar Aug 13 '22 01:08 brucethemoose

https://github.com/oracle/graal/commit/d570a0512f0f8e35ac4e9645f8560544788b7b9f fixes this. It will also be in the next release. Thanks for reporting this!

davleopo avatar Sep 14 '22 07:09 davleopo