PatchBukkit icon indicating copy to clipboard operation
PatchBukkit copied to clipboard

SIGSEGV on startup: null pointer passed to memcpy in ffi_native_bridge_get_server_info_impl

Open ckyuri opened this issue 1 month ago • 3 comments

SIGSEGV on startup: null pointer passed to memcpy in ffi_native_bridge_get_server_info_impl

Summary

With PatchBukkit loaded, the whole Pumpkin process crashes with exit code 139 (SIGSEGV) about 3.5 seconds after startup. The crash is in libc, called from ffi_native_bridge_get_server_info_impl in libpatchbukkit-X64-Linux.so. The copy's source pointer is null. It happens on every start. It is not an out-of-memory kill.

Environment

  • Pumpkin: 0.2.0+26.3-26.51 (Java protocol 777, Bedrock protocol 2193), nightly build, glibc binary pumpkin-X64-Linux, downloaded 2026-10-08
  • PatchBukkit: 0.1.0, libpatchbukkit-X64-Linux.so in plugins/ [release tag / commit / where you downloaded it]
  • Java: Temurin 25.0.4.1+1 LTS (ghcr.io/pterodactyl/yolks:java_25), JAVA_HOME=/opt/java/openjdk
  • OS inside container: Ubuntu 26.04.1 LTS, glibc 2.43
  • Host: AMD Ryzen 9 5950X, 15 GB RAM, kernel 5.15.0-191-generic
  • Runtime: Docker container managed by the Calagopus panel (Wings-compatible), run as ./pumpkin
  • JVM arguments (from the crash report): -XX:+IgnoreUnrecognizedVMOptions --enable-native-access=ALL-UNNAMED --enable-final-field-mutation=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED -Dcom.google.protobuf.useUnsafe=false

Steps to reproduce

  1. Install the glibc nightly Pumpkin binary on a Debian/Ubuntu-based Java 25 image.
  2. Place libpatchbukkit-X64-Linux.so in plugins/.
  3. Start the server with ./pumpkin.

Expected behaviour

PatchBukkit finishes initializing the JVM and the server keeps running.

Actual behaviour

Pumpkin logs "Server is now running", PatchBukkit starts initializing the JVM, the standard sun.misc.Unsafe warnings from org.joml.MemUtil appear, and then the process dies with SIGSEGV. The panel reports exit code 139 and Out of memory: false.

Log before the crash:

INFO patchbukkit: Starting PatchBukkit
INFO patchbukkit: Initializing JVM in background...
INFO patchbukkit: PatchBukkit loaded successfully
INFO Loaded patchbukkit (0.1.0)
INFO Server is now running. Connect using port: Java Edition: 0.0.0.0:25565 | Bedrock Edition: 0.0.0.0:19132
INFO patchbukkit::java::jvm::worker: Initializing JVM with assets path: "/home/container/plugins/data/patchbukkit/jassets"
INFO patchbukkit::java::jvm::worker: Found 1 JAR entries in jassets: [".../patchbukkit.jar"]
WARNING: sun.misc.Unsafe::objectFieldOffset has been called by org.joml.MemUtil$MemUtilUnsafe (...patchbukkit.jar)
# A fatal error has been detected by the Java Runtime Environment:
#  SIGSEGV (0xb) at pc=0x00007f777280ea0d, pid=1, tid=57
# Problematic frame:
# C  [libc.so.6+0x197a0d]

Crash analysis (from hs_err_pid1.log)

  • Signal: SIGSEGV, si_code: SEGV_MAPERR, si_addr: 0x0
  • Thread: main, state _thread_in_native
  • Faulting instruction (inside libc): vmovdqu ymm0, [rsi], with RSI=0x0, which is a memory copy from a null source pointer
  • Native frames:
C  [libc.so.6+0x197a0d]
C  [libpatchbukkit-X64-Linux.so+0x8fcf749]  patchbukkit::java::native_callbacks::server::ffi_native_bridge_get_server_info_impl+0x59
j  patchbukkit.bridge.NativeBridgeFfi.getServerInfo(Lpatchbukkit/common/EmptyRequest;)Lpatchbukkit/server/ServerInfoResponse;+50
j  org.patchbukkit.PatchBukkitServer.syncServerInfo()V+3
j  org.patchbukkit.PatchBukkitServer.<init>()V+517
j  org.patchbukkit.PatchBukkitServer.getInstance()Lorg/patchbukkit/PatchBukkitServer;+21
j  org.patchbukkit.PatchBukkitServer.initServer()Lorg/patchbukkit/PatchBukkitServer;+18
V  jni_CallStaticObjectMethodA
C  [libpatchbukkit-X64-Linux.so+0x913c60c]  jni::env::Env::call_static_method ...

Hypothesis (unconfirmed)

PatchBukkitServer.<init> calls syncServerInfo(), which calls into ffi_native_bridge_get_server_info_impl. That function appears to copy from a pointer that is null. Possible causes are that the server info it reads has not been initialized yet, because the JVM is started in the background during plugin load, or an ABI/version mismatch between this PatchBukkit build and this Pumpkin nightly. I could not confirm either from the outside.

Things already ruled out

  • Not an out-of-memory kill (Out of memory: false, heap max about 4 GB).
  • Not a missing or wrong Java: the JVM starts and runs patchbukkit.jar.
  • Not a musl/glibc problem: this uses the glibc build on a glibc system.
  • Not a signal-handler conflict: starting with LD_PRELOAD=$JAVA_HOME/lib/libjsig.so gave the identical crash at the same libc offset.

Reproducibility

Every start, at least 5 attempts. The libc offset (0x197a0d) and the thread id (57) were identical each time.

Workaround

Remove libpatchbukkit-X64-Linux.so from plugins/. Pumpkin then starts normally.

Attachments

  • hs_err_pid1.log

hs_err_pid1.log

ckyuri avatar Oct 08 '26 21:10 ckyuri

Double checking a step I took, if you have libpatchbukket installed, but don't include any plugin jars, does it start normally? I am able to get pumpkin to start in that state. IE plugins/data/patchbukkit/patchbukkit-plugins/ is either empty or has no jar files.

FamousL avatar Oct 09 '26 18:10 FamousL

It was completely empty, I never added anything as I would get a crashed state outside simply from having patchbukkit itself added. I had to create an updated egg to get past the issue of java being unavailable (and other required libs) as running on calagopus but that then was fine. I managed to figure it was just the patchbukkit current release .so being outdated (specifically the structs) and there are no guards written for a clean error so i would just get a raw segfault due to a memory offset being incorrect due the version mismatch.

tldr: build patchbukkit myself next time 😅

ckyuri avatar Oct 09 '26 19:10 ckyuri

I'll leave this open for now since I still do believe it could do with safeguard checks for this kind of issue

ckyuri avatar Oct 09 '26 19:10 ckyuri