[Native Image] MC server crashes when built with --pgo-instrument
option: WaitForSingleObject failed with error 0x57
#10251
Labels
--pgo-instrument
option: WaitForSingleObject failed with error 0x57
#10251
Describe the Issue
Native image tool is able to build a working executable of Minecraft server fork PaperMC if provided with enough metadata, but it crashes at runtime if built with
--pgo-instrument
command line option.Using the latest version of GraalVM can resolve many issues.
GraalVM Version
Oracle GraalVM for JDK 24 - early access build - 24.0.0-ea.22
Operating System and Version
Windows 11 23H2 22631.4317 amd64
Troubleshooting Confirmation
Run Command
See
Steps to Reproduce
section.Expected Behavior
To be able to build an executable with
--pgo-instrument
and to run it without problems.Actual Behavior
Runtime crash.
Steps to Reproduce
But, interestingly, although I didn't enable it via passing cmd arguments to native-image, mc server was crashing.
Stacktrace
Later I've checked how native executable will behave if compiled for linux aarch64 (Termux, ubuntu proot-distro) using the same GraalVM EA version, but I got the same exception message. Anyway I solved this problem by creating a patch for PaperMC and compiling it from source.
args.txt
file containing classpath argument and main class nameFirst, you'll need to accept Minecraft EULA. Edit
eula.txt
and seteula
value totrue
and then run the server again using the same command.Based on experience gained previously, it is indeed necessary to log into the server using the Minecraft client and perform some actions (generating chunks, joining other worlds, etc.), otherwise you will receive a file with incomplete metadata and will not be able to log into the server compiled to native executable.
You can download my example of working
reachablity_metadata.json
for Windows - link.reachability-metadata.json
By some reason, native image agent does not include all files of the data directory inside server jar into that file, but these are crucial for server to run, so replace:
with
--pgo-instrument
optionnogui
is mandatory or you'll getjava.lang.NoSuchMethodError: java.awt.Toolkit.getDefaultToolkit()Ljava/awt/Toolkit;
(by default it will try to open GUI window with console and memory monitor). Server should start up without problems.--pgo-instrument
optionServer will crash shortly after starting, at least on Windows.
Additional Context
Zip archive with:
--pgo-instrument
for Windows (ni-pgo-instrument
andni-normal
directories respectively)ni-normal
directory)reachability-metadata.json
for Windowslink.
If by some reason you can't to download zip files, you can download files from my repo.
Run-Time Log Output and Error Messages
The text was updated successfully, but these errors were encountered: