fix Linux segfault from stale JAWT drawable on OpenGL backend#766
Closed
jamesarich wants to merge 1 commit into
Closed
fix Linux segfault from stale JAWT drawable on OpenGL backend#766jamesarich wants to merge 1 commit into
jamesarich wants to merge 1 commit into
Conversation
Collaborator
|
I've also prompted AI to help investigate this, and it loves to flag this, but the segfault persists on Linux. This bug requires some deeper exploration (and actual testing on a Linux machine) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #564
The segfault inside
render()was caused by incorrect JAWT usage:Display*andDrawablewere captured once inJawtContext's constructor and cached forever. The JAWT spec requires re-fetching surface info after everyLock()call — the X11Drawable(window ID) changes when the AWT peer is recreated on first show, on resize, or whenJAWT_LOCK_SURFACE_CHANGEDis returned. Passing a staleDrawabletoglXMakeCurrent/glXSwapBuffersis what causes the crash.Raised as one of the items in @sargunv's comment at sargunv/maplibre-native#2 (comment).
Changes
jawt_context.hpp—lock()now callsGetDrawingSurfaceInfo()after eachLock()and refreshes platform surface info (display, drawable, etc.);unlock()callsFreeDrawingSurfaceInfo()beforeUnlock(), following the required JAWT lifecycle. Constructor simplified to a single lock/unlock to initialise theDisplay*(which is the JVM's persistent X11 connection and never changes).canvas_opengl_backend.cpp— destructor: replacecheck()(throws from a destructor → UB during stack unwinding) with an early-return guard; useglXMakeCurrent(display, None, nullptr)to release the context without needing a valid window;activate()checks theglXMakeCurrentreturn value and throws a descriptive error on failure rather than silently proceeding with no current context;deactivate()also usesNoneas the drawable when releasing, for consistency.canvas_frontend.cpp— remove the TODO comment that flagged the segfault.Checklist
To your knowledge, are you making any breaking changes? No.
Have you tested the changes? On which platforms?