wlroots-hyprland/types
Alexander Orzechowski cddc1c1bd9 xdg-foreign: Fix crash on destroy of degenerate surface
I am running a custom compiled version of chromium with a patch to get
it up and running on sway git at the moment, and in that development
build I compiled there is a bug where the browser will crash if you
try to open a file select dialog. When this crash happens, chromium will
not close, but instead will remain open and impossible to close unless
you send a SIGKILL signal to the process. However, sway will crash to
tty when you send the SIGKILL.

I have a hunch that when chromium is opening the file select dialog
it is creating some sort of a xdg toplevel surface. But it freezes
before it fully initializes the surface. When the SIGKILL signal is
given, sway/wlroots will try to free the xdg_toplevel surface but
because it hasn't fully initialized due to the frozen window, it
segfaults.

Don't be fooled by the assert, the assert is not firing, the surface
pointer is indeed NULL here.

* thread #1, name = 'sway', stop reason = signal SIGSEGV: invalid address (fault address: 0x28)
    frame #0: 0x00007ffff78b9041 libwlroots.so.11`wlr_xdg_toplevel_set_parent(surface=0x0000000000000000, parent=0x0000000000000000) at wlr_xdg_toplevel.c:159:37
   156
   157 	void wlr_xdg_toplevel_set_parent(struct wlr_xdg_surface *surface,
   158 			struct wlr_xdg_surface *parent) {
-> 159 		assert(surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL);
   160 		assert(!parent || parent->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL);
   161
   162 		if (surface->toplevel->parent) {
(lldb) up
error: sway {0x0003442a}: DIE has DW_AT_ranges(DW_FORM_sec_offset 0x67) attribute, but range extraction failed (invalid range list offset 0x67), please file a bug and attach the file at the start of this error message
error: sway {0x0003442a}: DIE has DW_AT_ranges(DW_FORM_sec_offset 0x67) attribute, but range extraction failed (invalid range list offset 0x67), please file a bug and attach the file at the start of this error message
frame #1: 0x00007ffff78e176e libwlroots.so.11`destroy_imported(imported=0x000055555626d570) at wlr_xdg_foreign_v1.c:154:3
   151 		wl_list_for_each_safe(child, child_tmp, &imported->children, link) {
   152 			struct wlr_xdg_surface *xdg_child =
   153 				wlr_xdg_surface_from_wlr_surface(child->surface);
-> 154 			wlr_xdg_toplevel_set_parent(xdg_child, NULL);
   155 		}
   156
   157 		wl_list_remove(&imported->exported_destroyed.link);
(lldb) up
frame #2: 0x00007ffff78e1b9d libwlroots.so.11`xdg_imported_handle_resource_destroy(resource=0x00005555562555a0) at wlr_xdg_foreign_v1.c:280:2
   277 			struct wl_resource *resource) {
   278 		struct wlr_xdg_imported_v1 *imported = xdg_imported_from_resource(resource);
   279 		if (!imported) {
-> 280 			return;
   281 		}
   282
   283 		destroy_imported(imported);
(lldb) up
frame #3: 0x00007ffff794989a libwayland-server.so.0`___lldb_unnamed_symbol211 + 154
libwayland-server.so.0`___lldb_unnamed_symbol211:
->  0x7ffff794989a <+154>: andl   $0x1, %r13d
    0x7ffff794989e <+158>: je     0x7ffff79498b0            ; <+176>
    0x7ffff79498a0 <+160>: addq   $0x8, %rsp
    0x7ffff79498a4 <+164>: movl   $0x1, %eax
(lldb) up
frame #4: 0x00007ffff794fec0 libwayland-server.so.0`___lldb_unnamed_symbol290 + 64
libwayland-server.so.0`___lldb_unnamed_symbol290:
->  0x7ffff794fec0 <+64>: cmpl   $0x1, %eax
    0x7ffff794fec3 <+67>: jne    0x7ffff794fed3            ; <+83>
    0x7ffff794fec5 <+69>: addq   $0x8, %rbx
    0x7ffff794fec9 <+73>: cmpq   %rbx, %r13
(lldb) up
frame #5: 0x00007ffff79503e0 libwayland-server.so.0`___lldb_unnamed_symbol300 + 32
libwayland-server.so.0`___lldb_unnamed_symbol300:
->  0x7ffff79503e0 <+32>: cmpl   $0x1, %eax
    0x7ffff79503e3 <+35>: je     0x7ffff79503f0            ; <+48>
    0x7ffff79503e5 <+37>: popq   %rbx
    0x7ffff79503e6 <+38>: popq   %r12
(lldb) up
frame #6: 0x00007ffff794a30e libwayland-server.so.0`wl_client_destroy + 126
libwayland-server.so.0`wl_client_destroy:
->  0x7ffff794a30e <+126>: movq   %r12, %rdi
    0x7ffff794a311 <+129>: callq  0x7ffff7950150            ; ___lldb_unnamed_symbol293
    0x7ffff794a317 <+135>: movq   0x8(%rbp), %rdi
    0x7ffff794a31b <+139>: callq  *0xdc77(%rip)
(lldb) up
frame #7: 0x00007ffff794a3f7 libwayland-server.so.0`___lldb_unnamed_symbol214 + 119
libwayland-server.so.0`___lldb_unnamed_symbol214:
->  0x7ffff794a3f7 <+119>: movq   0x28(%rsp), %rax
    0x7ffff794a3fc <+124>: subq   %fs:0x28, %rax
    0x7ffff794a405 <+133>: jne    0x7ffff794a727            ; <+935>
    0x7ffff794a40b <+139>: addq   $0x38, %rsp
(lldb) up
frame #8: 0x00007ffff794d1ca libwayland-server.so.0`wl_event_loop_dispatch + 202
libwayland-server.so.0`wl_event_loop_dispatch:
->  0x7ffff794d1ca <+202>: addq   $0xc, %r15
    0x7ffff794d1ce <+206>: cmpq   %r15, %rbp
    0x7ffff794d1d1 <+209>: jne    0x7ffff794d1b8            ; <+184>
    0x7ffff794d1d3 <+211>: movq   0x8(%rsp), %rcx
(lldb) up
frame #9: 0x00007ffff794ad37 libwayland-server.so.0`wl_display_run + 39
libwayland-server.so.0`wl_display_run:
->  0x7ffff794ad37 <+39>: movl   0x8(%rbx), %eax
    0x7ffff794ad3a <+42>: testl  %eax, %eax
    0x7ffff794ad3c <+44>: jne    0x7ffff794ad20            ; <+16>
    0x7ffff794ad3e <+46>: popq   %rbx
(lldb) up
frame #10: 0x000055555557689a sway`server_run(server=0x00005555555f26c0) at server.c:307:2
   304 			wlr_backend_destroy(server->backend);
   305 			return false;
   306 		}
-> 307
   308 		return true;
   309 	}
   310
(lldb) up
frame #11: 0x0000555555575a93 sway`main(argc=3, argv=0x00007fffffffe978) at main.c:431:2
   428 			swaynag_show(&config->swaynag_config_errors);
   429 		}
   430
-> 431 		server_run(&server);
   432
   433 	shutdown:
   434 		sway_log(SWAY_INFO, "Shutting down sway");
2022-02-02 17:56:23 +00:00
..
data_device surface: deprecate wlr_surface.h 2022-01-13 10:06:41 +00:00
output surface: deprecate wlr_surface.h 2022-01-13 10:06:41 +00:00
scene scene: Add layer_shell_v1 helper 2022-02-01 13:31:26 +01:00
seat surface: deprecate wlr_surface.h 2022-01-13 10:06:41 +00:00
tablet_v2 surface: deprecate wlr_surface.h 2022-01-13 10:06:41 +00:00
xdg_shell surface: improve role precommit hook 2022-01-13 15:15:54 +03:00
meson.build ext-session-lock-v1: new protocol implementation 2022-02-02 15:22:02 +01:00
wlr_buffer.c types/buffer: make {begin,end}_data_ptr_access part of the public API 2021-09-15 11:50:44 +02:00
wlr_compositor.c compositor: damage the whole buffer on viewport src change 2022-01-22 12:09:48 +03:00
wlr_cursor.c cursor: ensure mapping box is always initialized 2022-01-31 21:00:20 +03:00
wlr_data_control_v1.c Simplify globals implementation by removing destructors 2019-11-25 09:01:46 -05:00
wlr_drm.c drm: add support for DMA-BUFs 2021-07-05 11:13:41 -04:00
wlr_drm_lease_v1.c util/global: remove wl_display arg from wlr_global_destroy_safe 2021-12-14 13:13:50 +00:00
wlr_export_dmabuf_v1.c export-dmabuf-v1: use wlr_output_event_commit.buffer 2021-12-03 14:56:17 +00:00
wlr_foreign_toplevel_management_v1.c foreign-toplevel: send enter if needed on output bind 2022-01-17 19:11:08 +01:00
wlr_fullscreen_shell_v1.c surface: deprecate wlr_surface.h 2022-01-13 10:06:41 +00:00
wlr_gamma_control_v1.c gamma-control-v1: schedule frame when resetting gamma LUT 2021-01-10 18:40:08 +01:00
wlr_idle.c Simplify globals implementation by removing destructors 2019-11-25 09:01:46 -05:00
wlr_idle_inhibit_v1.c surface: deprecate wlr_surface.h 2022-01-13 10:06:41 +00:00
wlr_input_device.c Remove all wayland-server.h includes 2019-07-27 15:49:32 -04:00
wlr_input_inhibitor.c Make implementation function lists static const 2021-02-05 10:04:20 +01:00
wlr_input_method_v2.c input_method_v2: improve mapping detection 2022-01-16 09:08:39 -07:00
wlr_keyboard.c keyboard: add wlr_keyboard.keymap_fd 2021-09-05 22:06:25 +02:00
wlr_keyboard_group.c Replace wlr_key_state with wl_keyboard_key_state 2020-11-11 10:58:38 +01:00
wlr_keyboard_shortcuts_inhibit_v1.c surface: deprecate wlr_surface.h 2022-01-13 10:06:41 +00:00
wlr_layer_shell_v1.c surface: improve role precommit hook 2022-01-13 15:15:54 +03:00
wlr_linux_dmabuf_v1.c surface: deprecate wlr_surface.h 2022-01-13 10:06:41 +00:00
wlr_matrix.c move wlr_box from /types to /util 2021-07-06 21:43:17 +02:00
wlr_output_damage.c output-damage: fix damage on modeset 2021-09-07 22:27:31 +02:00
wlr_output_layout.c output-layout: remove useless types/fields 2022-01-31 10:32:47 +00:00
wlr_output_management_v1.c output-management: use same types as wlr_output 2021-01-10 16:28:19 +01:00
wlr_output_power_management_v1.c output-power-management-v1: listen to output commit 2020-08-27 13:54:19 -06:00
wlr_pointer.c pointer: add hold pointer event definition 2021-09-27 15:30:31 +02:00
wlr_pointer_constraints_v1.c surface: deprecate wlr_surface.h 2022-01-13 10:06:41 +00:00
wlr_pointer_gestures_v1.c surface: deprecate wlr_surface.h 2022-01-13 10:06:41 +00:00
wlr_presentation_time.c surface: deprecate wlr_surface.h 2022-01-13 10:06:41 +00:00
wlr_primary_selection.c wlr_seat: Fix edge cases with serial validation 2019-06-30 15:01:05 -04:00
wlr_primary_selection_v1.c primary selection: destroy devices before manager 2021-01-05 13:53:58 +01:00
wlr_region.c region: stabilize interface 2021-07-05 09:25:25 -04:00
wlr_relative_pointer_v1.c Simplify globals implementation by removing destructors 2019-11-25 09:01:46 -05:00
wlr_screencopy_v1.c screencopy-v1: use wlr_output_event_commit.buffer 2021-12-03 14:56:17 +00:00
wlr_server_decoration.c surface: deprecate wlr_surface.h 2022-01-13 10:06:41 +00:00
wlr_session_lock_v1.c ext-session-lock-v1: new protocol implementation 2022-02-02 15:22:02 +01:00
wlr_subcompositor.c subsurface: unlock cached state on commit if desynced 2022-01-25 22:41:30 +03:00
wlr_switch.c Remove all wayland-server.h includes 2019-07-27 15:49:32 -04:00
wlr_tablet_pad.c Fix invalid uses of wl_array_for_each 2021-07-08 10:08:47 -04:00
wlr_tablet_tool.c Fix invalid uses of wl_array_for_each 2021-07-08 10:08:47 -04:00
wlr_text_input_v3.c surface: deprecate wlr_surface.h 2022-01-13 10:06:41 +00:00
wlr_touch.c touch: add frame event 2021-07-08 09:12:17 +02:00
wlr_viewporter.c surface: deprecate wlr_surface.h 2022-01-13 10:06:41 +00:00
wlr_virtual_keyboard_v1.c virtual_keyboard: Emulate key release events on destroy 2021-05-07 11:18:19 +02:00
wlr_virtual_pointer_v1.c Fix incorrect format parameters 2020-07-27 10:49:19 +02:00
wlr_xcursor_manager.c Make wlr_xcursor_manager_load() return a bool 2020-05-18 16:48:44 +02:00
wlr_xdg_activation_v1.c surface: deprecate wlr_surface.h 2022-01-13 10:06:41 +00:00
wlr_xdg_decoration_v1.c xdg-decoration: refactor configure/state flow 2021-10-07 07:27:51 -06:00
wlr_xdg_foreign_registry.c util/uuid: replace with util/token, remove libuuid 2021-04-11 19:09:36 +02:00
wlr_xdg_foreign_v1.c xdg-foreign: Fix crash on destroy of degenerate surface 2022-02-02 17:56:23 +00:00
wlr_xdg_foreign_v2.c xdg-foreign: Fix crash on destroy of degenerate surface 2022-02-02 17:56:23 +00:00
wlr_xdg_output_v1.c xdg-output: remove dead code 2022-01-28 17:38:39 +01:00