-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix crashes on exit caused by wlroots listener checks #8578
base: master
Are you sure you want to change the base?
Conversation
On second thought, it might be more useful to remove the bulk of the listeners in Destroy listeners are still needed for a bunch of other components that aren't directly created in |
If we could have a 1:1 mapping between what is set up in One thing is what is easiest to implement, another is what is easiest to maintain and catch errors within in the future. |
8ea9677
to
307ce0c
Compare
IMO components that have This is sometimes hard to distinguish though; I'm currently handling these by making the I think I'll try to get this PR far enough to exit sway without crashes with this method, keeping as much as possible in separate commits for reviewability, and we'll sort out what the best path forward is during review. |
adfe709
to
8ee1fc7
Compare
The current state makes sway exit correctly from a desktop containing a few konsole windows and a firefox window. I'm not completely sure about the correct handling of all of these cases, and I'm sure there are a lot more objects with listeners that need to be removed before destroy, but those don't trigger on a regular exit in my setup. I've already started writing a script to search for all objects in wlroots that have listener checks and their corresponding usages in sway, but that might take a while. In the meantime, I think it's better to mark this as reviewable now and see where we go afterwards. |
8ee1fc7
to
6df3682
Compare
Addendum to this: this works fine for The current implementation has this 1:1 mapping for objects created in |
6df3682
to
ca19d20
Compare
Diff to state before last force-push: diff --git a/sway/server.c b/sway/server.c
index 683ce169..79c8f542 100644
--- a/sway/server.c
+++ b/sway/server.c
@@ -458,6 +458,7 @@ bool server_init(struct sway_server *server) {
void server_fini(struct sway_server *server) {
// remove listeners
+ wl_list_remove(&server->renderer_lost.link);
wl_list_remove(&server->new_output.link);
wl_list_remove(&server->layer_shell_surface.link);
wl_list_remove(&server->xdg_shell_toplevel.link);
@@ -474,14 +475,12 @@ void server_fini(struct sway_server *server) {
wl_list_remove(&server->xdg_activation_v1_request_activate.link);
wl_list_remove(&server->xdg_activation_v1_new_token.link);
wl_list_remove(&server->request_set_cursor_shape.link);
-#if WLR_HAS_XWAYLAND
- wl_list_remove(&server->xwayland_surface.link);
- wl_list_remove(&server->xwayland_ready.link);
-#endif
input_manager_finish(server);
// TODO: free sway-specific resources
#if WLR_HAS_XWAYLAND
+ wl_list_remove(&server->xwayland_surface.link);
+ wl_list_remove(&server->xwayland_ready.link);
wlr_xwayland_destroy(server->xwayland.wlr_xwayland);
#endif
wl_display_destroy_clients(server->wl_display); |
This fixes a crash in wlroots listener checks. See swaywm#8509.
This fixes a crash in wlroots listener checks. See swaywm#8509.
This fixes a crash in wlroots listener checks. See swaywm#8509.
sway_input_method_relay can be destroyed from two sources, either the seat is destroyed or the manager protocol objects are destroyed due compositor exit. Therefore, finish must check whether it has already been called. This fixes a crash in wlroots listener checks. See swaywm#8509.
Change begin_destroy to remove event listeners before the final destroy, since otherwise event listeners would be removed twice, which crashes. This fixes a crash in wlroots listener checks. See swaywm#8509.
ca19d20
to
8932123
Compare
This PR fixes sway crashing on exit due to event listeners not being removed from wlroots objects on exit.
Listeners fixed:
server_init()
wlr_backend.new_input
,wlr_virtual_keyboard
,wlr_virtual_pointer
,wlr_keyboard_shortcuts_inhibit
,wlr_transient_seat_manager
wlr_idle_inhibit_manager
wlr_text_input_manager
andwlr_input_method_manager
wlr_scene_buffer.output_enter
andwlr_scene_buffer.output_leave
This doesn't fix all wlroots objects with listener checks, just those that lead to immediate crashes on exit. I'll wait for a review of my general method of fixing this before continuing.