Skip to content

update to jmonkeyengine 3.10.0-beta2 + lwjgl 3 - #716

Merged
neph1 merged 7 commits into
jMonkeyEngine:masterfrom
neph1:upgrade_lwjgl
Nov 11, 2026
Merged

neph1 merged 7 commits into
jMonkeyEngine:masterfrom
neph1:upgrade_lwjgl

Conversation

@neph1

@neph1 neph1 commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

fixes #715

@neph1 neph1 changed the title Upgrade lwjgl update to jmonkeyengine 3.10.0-beta2 + lwjgl 3 Sep 11, 2026
@neph1

neph1 commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor Author

Currently causes a crash on exit.

neph1 and others added 4 commits September 14, 2026 08:43
Quit the SDK and the JVM died with SIGSEGV during process teardown,
reliably, whenever the offscreen scene application had started:

  Current thread is native thread
  # C [libc.so.6+0x91651]        <- __GI___nptl_deallocate_tsd
  SIGSEGV (SEGV_MAPERR)

Root cause (proven via strace mmap/munmap correlation, a coredump
backtrace and four hs_err logs with identical state; pthread key
index 14 and the same destructor offset ...d30 in every sample):

- GLFW (jME lwjgl3 backend) probes EGL besides GLX while creating
  the GL context for the offscreen scene application.
- glvnd's libEGL.so.1 registers a pthread_key whose destructor points
  into its own text, and stores per-thread TSD data on the render
  thread that made the egl* calls. The key is never deleted.
- At SDK shutdown GLFW terminates and dlcloses libEGL.so.1 (strace:
  munmap of its whole 75432-byte mapping during the teardown cascade).
  The registered destructor is now dangling.
- When the render thread finishes and glibc runs the thread-exit TSD
  walker (__nptl_deallocate_tsd), it calls the stale destructor into
  the unmapped libEGL text -> SIGSEGV -> JVM fatal error.
  Timing-wise this is a race: occasionally the thread exits before
  the dlclose and the exit looks clean.

Fix: hold our own dlopen reference on libEGL.so.1 at module startup
(System.load in the jme3-core Installer, Linux only). GLFW's dlclose
then merely drops its own reference: the library stays mapped until
the JVM terminates and the destructor remains valid.

Verified: traced runs before the fix crashed on every exit; with the
pin, exits are clean (no hs_err, no coredump, libEGL never unmapped)
across repeated straced and plain runs.

A complete fix should also be pursued upstream (glvnd removing its
pthread key on library unload, or GLFW not unloading libraries it
probed).

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
The fix commit for the exit crash holds a dlopen reference on
libEGL.so.1 to keep glvnd's pthread-key destructor valid. Its
comments and log message blamed GLFW for the load/unload of libEGL.
jME 3.10's lwjgl3 backend is SDL3-based (LWJGL 3.4 lwjgl-sdl
bindings; there is no lwjgl-glfw on the SDK classpath): SDL probes
the X11 and Wayland/EGL video backends when the GL context is
created, and its video teardown (SDL_EGL_UnloadLibrary) dlcloses
libEGL at shutdown, leaving the destructor dangling. Same crash,
same pthread key, same fix - only the actor is SDL3, not GLFW.

Wording-only change, no functional difference.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
@neph1

neph1 commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

Regarding why only linux:

So the specific bug is Linux-bound: only there does a library exist that registers a destructor it
never deregisters (glvnd), only for the platform runtime to keep calling it after the dlclose
(glibc). On Windows the worst case from an unloaded-with-TLS library is a leak, not a SIGSEGV; on
macOS the offending registrar simply isn't in the code path.

Two honest caveats:

  1. I haven't empirically verified Windows/macOS — no test machines in this session. If users on
    those platforms ever report an exit crash, the analog investigation applies (Process
    Monitor/handle tracing on Windows; dtruss/DYLD_PRINT_LIBRARIES on macOS). One thing worth keeping
    in mind: the SDK's classpath does bundle angle-natives (LWJGL's EGL-on-Windows/Mac story), so if
    any future code path requests GLES/ANGLE contexts via SDL, an EGL probe could happen there — at
    that point revisiting the pin for those platforms would be warranted.
  2. The Linux guard is designed to degrade gracefully: if libEGL.so.1 isn't found (bare server
    distro, exotic layout), it logs and no-ops — and in precisely that situation there'd be no EGL
    probe to crash on anyway. On non-Linux it no-ops without touching anything.
    ▂
    So: not incomplete for the failure mode we diagnosed — guarding other platforms would be speculative
    code for a mechanism that, as far as the evidence shows, doesn't assemble there.

@tonihele

tonihele commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Hmm, is this a bug in LWJGL ?

@neph1

neph1 commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor Author

It talks about upstream, so yeah maybe. If anyone can casually nudge the lwjgl team to look at this, please do.(Note, it talks about GLFW, but it's actually SDL which is corrected in the latter commit message).

@neph1
neph1 merged commit 8299d34 into jMonkeyEngine:master Nov 11, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use LWJGL 3

2 participants