Skip to content

fix: avoid crash when X display is unavailable - #609

Open
blackthunder0812 wants to merge 2 commits into
BambooEngine:masterfrom
blackthunder0812:fix/no-display-crash
Open

blackthunder0812 wants to merge 2 commits into
BambooEngine:masterfrom
blackthunder0812:fix/no-display-crash

Conversation

@blackthunder0812

Copy link
Copy Markdown

Summary

  • avoid dereferencing a null Display * when no X server is available
  • return an empty window class so Bamboo can continue with its default input mode
  • add a regression test for activating the X11 introspection fallback with DISPLAY unset

Problem

On a pure GNOME Wayland session (gnome-shell --no-x11), DISPLAY is unset. If GNOME window-class introspection returns no value, Bamboo falls back to x11GetFocusWindowClass(). XOpenDisplay(NULL) then returns NULL, but the code passes that pointer to XGetInputFocus(), causing the engine to crash during FocusIn().

Observed crash:

SIGSEGV: segmentation violation
...
main._Cfunc_x11GetFocusWindowClass()
main.x11GetFocusWindowClass()
main.(*IBusBambooEngine).getLatestWmClass()
main.(*IBusBambooEngine).FocusIn()

This makes GNOME appear to select Bamboo and immediately fall back to the English input source. It is especially visible in native Wayland Chromium with text-input-v3 enabled.

Verification

  • make test passes
  • make build passes
  • the new targeted test passes with the fix
  • sabotage verification: removing the null check makes the new test terminate with the original SIGSEGV
  • a patched v0.8.5 binary was exercised on GNOME 50.4 Wayland with DISPLAY unset and successfully typed Vietnamese in native Wayland Chrome 151

Related to #44, but this PR only fixes the no-X-display crash; it does not claim complete Wayland feature parity.

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.

2 participants