Skip to content

libobs: Treat a NULL X11 keymap reply as nothing pressed - #231

Merged
zackees merged 2 commits into
masterfrom
fix/126-x11-null-keymap
Oct 11, 2026
Merged

zackees merged 2 commits into
masterfrom
fix/126-x11-null-keymap

Conversation

@zackees

@zackees zackees commented Oct 11, 2026

Copy link
Copy Markdown
Member

Fixes #126.

When the X connection is closing or broken, xcb_query_keymap_reply() returns NULL with no error. key_pressed() only checked error, so the hotkey thread read the key bits from NULL and crashed, at shutdown and (under valgrind) at startup. The sanitizer workflow hit this in all three of its passes.

  • RED: the bit test moves, unchanged, into libobs/obs-nix-x11-keymap.h, which needs only the xcb reply type. test_x11_keymap failed: null_reply_is_not_pressed hit Segmentation fault(11) (Tier 2 passed 76 of 77).
  • GREEN: a NULL reply means nothing is pressed. Tier 2 passed 77 of 77 with ENABLE_RUST_LIBOBS OFF and 77 of 77 with it ON.

Local gate: lint, rust-test and tier2-linux all passed.

zackees and others added 2 commits October 11, 2026 04:15
xcb_query_keymap_reply() returns NULL with no error when the X
connection is closing or broken, and key_pressed() then read the key
bits from NULL, crashing the hotkey thread at startup or shutdown
(#126). Moves the bit test into obs-nix-x11-keymap.h unchanged and adds
test_x11_keymap. null_reply_is_not_pressed crashes with SIGSEGV.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
obs_nix_x11_keycode_pressed() returns false for a NULL reply, so the
hotkey thread no longer crashes when xcb_query_keymap fails without
an error. test_x11_keymap passes.

Fixes #126

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Local-Gate: v1 tree=01b25b4a2501098ca8e0e10e3a29f8aeb089e555 secs=120 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791717528,"gate":"rust/all/fmt","host":"linux-x86_64","key":"ae98e72e0eff40fcf58123d48dd82be068455992034b66efb25494ba1af712cb","lane":"lint","parents":["28eb7c6e3fe5e041e2e53e7ebdf2747b3b88d6be"],"secs":48,"stamp":"b6a7b436ca74a64921f049e9f5c3985c","tree":"01b25b4a2501098ca8e0e10e3a29f8aeb089e555","v":1,"via":"run"}
Ci-Attestation: {"at":1791717528,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"ae98e72e0eff40fcf58123d48dd82be068455992034b66efb25494ba1af712cb","lane":"lint","parents":["28eb7c6e3fe5e041e2e53e7ebdf2747b3b88d6be"],"secs":48,"stamp":"c75ab3c63b11976544247f2e5e7c6388","tree":"01b25b4a2501098ca8e0e10e3a29f8aeb089e555","v":1,"via":"run"}
Ci-Attestation: {"at":1791717528,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"9f8533de03bcb57be20326af57e0cb18dd23c63e15af7f5c1dd7541e03c21ea1","lane":"rust-test","parents":["28eb7c6e3fe5e041e2e53e7ebdf2747b3b88d6be"],"secs":29,"stamp":"9cf837e33e62c69bc6585fe9ff2095cc","tree":"01b25b4a2501098ca8e0e10e3a29f8aeb089e555","v":1,"via":"run"}
Ci-Attestation: {"at":1791717528,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"54958d783f3ae958606e50fedf075ad3eb72e333a9efb13e1ab9c02d23dba666","lane":"tier2-linux","parents":["28eb7c6e3fe5e041e2e53e7ebdf2747b3b88d6be"],"secs":43,"stamp":"4cd9eeb5da8ebda661cfd29157e0155e","tree":"01b25b4a2501098ca8e0e10e3a29f8aeb089e555","v":1,"via":"run"}
@zackees
zackees merged commit 2b9beb3 into master Oct 11, 2026
23 checks passed
@zackees
zackees deleted the fix/126-x11-null-keymap branch October 26, 2026 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

ASan: SEGV in X11 hotkey thread (keycode_pressed) on shutdown — NULL xcb_query_keymap reply

1 participant