Repository navigation
gtk: fix crash caused by missing dbus connection - #13101
Merged
Merged
Conversation
Changes GlobalShortcuts.refresh to do nothing when there is no dbus connection and GlobalShortcuts.close to always clean up arena memory.
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 #13075 where GTK app will crash if a D-Bus connection can't be opened. If you have global keybinds set in your config, Ghostty will crash immediately in both debug and release builds. With no global keybinds it still crashes when you reload the config, but only in builds with safety checks enabled, due to a failed assertion.
This problem is rooted in
GlobalShortcuts, which implements the XDG global shortcuts protocol. Therefreshfunction is triggered every time the config changes and once on startup. If there are global keybinds in the config but no D-Bus connection,refreshwill still try to setup the global keybinds by calling therequestmethod, which will usepriv.dbus_connection.?while the field is null. Depending on the build mode this either fails the Zig runtime safety check immediately or eventually causes a segmentation fault somewhere ingio/glibwhen the null pointer is used.Additionally, even if there are no global keybinds set, Ghostty will still crash when the config is reloaded, because the
closefunction exits early ifdbus_connectionis null and doesn't clean up the arena that was created in the first call torefreshon startup. The next call torefreshwill then fail thepriv.arena == nullassertion. This only happens if built with safety checks enabled.As a fix
closewill now always clean up the arena andrefreshwill exit early if there is no D-Bus connection.To easily reproduce the crash, change
Application.startupGlobalShortcuts(insrc/apprt/gtk/class/application.zig) to set the D-Bus connection to null withpriv.global_shortcuts.setDbusConnection(null). Then run with a global keybind e.g.ghostty --keybind="global:ctrl+o=toggle_quick_terminal".AI Disclosure
No AI was used.