8000 X11: handle unavailable input methods without freeing the default GC by lcasarin-maker · Pull Request #445 · emoon/rust_minifb · GitHub
[go: up one dir, main page]

Skip to content

X11: handle unavailable input methods without freeing the default GC - #445

Merged
emoon merged 1 commit into
emoon:masterfrom
lcasarin-maker:fix/x11-input-method-and-gc-ownership
Nov 22, 2026
Merged

emoon merged 1 commit into
emoon:masterfrom
lcasarin-maker:fix/x11-input-method-and-gc-ownership

Conversation

@lcasarin-maker
Copy link
Copy Markdown
Contributor

An X11 window can fail to open its configured input method. At that point
DisplayInfo still holds the display-owned default GC. Freeing it explicitly
and then closing the display can release the same object twice. On an Xvfb
display, this was observable as SIGSEGV from XCloseDisplay.

This patch leaves the GC unowned until XCreateGC succeeds, and it frees only
that owned GC. It retains the configured input method when available. If
XOpenIM fails, the window can still show and accept basic keys without an XIC.
The initialization and shutdown paths guard resources that may be absent.

The first reproductions used a minimal RePic GUI session with synthetic images.
With the published 0.29.0 dependency, XMODIFIERS=@im=ibus on isolated Xvfb
returned 139. The patched library opened and exited normally. A 16-bit Xvfb
display returned a window-creation error with the patch instead of SIGSEGV.
The patch applies to upstream master at 2f9fe002de9d9850218fda3874215e8a4633dc62.

Upstream validation

Built the repository's noise example on the same revision before and after
applying the patch, with separate Cargo target directories:

cargo build --locked --no-default-features --features x11 --example noise
XMODIFIERS=@im=ibus xvfb-run -a -s '-screen 0 1280x800x24' target/debug/examples/noise

The original returned 139. The patched example displayed
Noise Test - Press ESC to exit and returned 0 after Escape.
cargo test --locked --no-default-features --features x11 --lib passed all
14 upstream unit tests on AArch64 Linux.

@emoon
emoon merged commit f10316c into emoon:master Nov 22, 2026
5 checks passed
@emoon
emoon commented Nov 22, 2026
Copy link
Copy Markdown
Owner

Thanks!

emoon added a commit that referenced this pull request Nov 22, 2026
Move the xic/xim/window release into one helper used by the error paths
and Drop, which also stops leaking the window when XCreateIC fails. An
XCreateIC failure now degrades to XLookupString like an XOpenIM failure.
Add changelog entries for #445 and the fallback.
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

0