Skip to content

libobs: Fix Wayland segfault on shutdown#13610

Open
joepadmiraal wants to merge 1 commit into
obsproject:masterfrom
joepadmiraal:segfault_during_app_shutdown
Open

libobs: Fix Wayland segfault on shutdown#13610
joepadmiraal wants to merge 1 commit into
obsproject:masterfrom
joepadmiraal:segfault_during_app_shutdown

Conversation

@joepadmiraal

@joepadmiraal joepadmiraal commented Jun 30, 2026

Copy link
Copy Markdown

Description

The keyboard_listener events can still be triggered after obs_nix_wayland_hotkeys_platform_free has been called, resulting in a segfault inside rebuild_keymap_data. Add a call to wl_keyboard_release to prevent new events from being triggered.

Motivation and Context

I was running OBS 32.1.2 on Ubuntu26.04 and when I closed it the app crashed.
An Ubuntu Apport dialog appeared and after investigating the core dump I found the issue.

#0  xkb_keymap_key_get_syms_by_level()       libxkbcommon      <-- SIGSEGV
#1  load_keymap_data()                       libobs           (obs-nix-wayland.c:48-67)
#2  xkb_keymap_key_for_each()                libxkbcommon     (iterates keymap, calls #1)
#3  libffi
#4  libffi
#5  ffi_call()                               libffi           (Wayland invokes the listener)
#6  libwayland-client
#7  libwayland-client
#8  wl_display_dispatch_queue_pending()      libwayland-client
#9  QtWaylandClient::QWaylandDisplay::flushRequests()
#10 QEventDispatcherGlib::processEvents()    libQt6Core
#11 QEventLoop::exec()                       libQt6Core
#12 QCoreApplication::exec()                 libQt6Core
#13 obs main

How Has This Been Tested?

Since this is a race condition its very hard to reproduce.
I let Claude make a reproduction with a copy of the relevant code from obs-nix-wayland.c and verified with AddressSanitizer.

After the fix I also compiled OBS and ran it couple of times to see if no new shutdown errors appeared.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have read the contributing document.
  • My code has been run through clang-format.
  • My code follows the project's style guidelines
  • My code is not on the master branch.
  • My code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

The keyboard_listener events can still be triggered after
obs_nix_wayland_hotkeys_platform_free has been called, resulting
in a segfault inside rebuild_keymap_data. Add a call to
wl_keyboard_release to prevent new events from being triggered.
@WizardCM WizardCM added kind/bug Categorizes issue or PR as related to a bug. platform/linux Categorizes issue or PR as affecting Linux specifically labels Jul 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Categorizes issue or PR as related to a bug. platform/linux Categorizes issue or PR as affecting Linux specifically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants