sway: sway crashes when interacting with chromium

  • Sway Version:

sway version 1.10-dev-2686afb9 (May 7 2024, branch ‘master’)

  • Debug Log:

https://paste.sr.ht/~whynothugo/95a3445a0e678c2a642994d7662d5f0357ae1d14

  • Stack Trace:

I didn’t run sway with gdb; will try again and follow-up.

  • Description:

Interacting with chromium makes sway crash. Sometimes it’s when right clicking, but often times this happens when toggling fullscreen.

I can’t find an exact reproducer. Opening a terminal and chromium and moving the windows around / toggling full screen seems to toggle it. Sometimes it happens at the first right-click.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 6
  • Comments: 34 (18 by maintainers)

Most upvoted comments

It’s a wlroots issue. If a client sends bad state, it should never crash the entire compositor.

I’m triggering what I’m currently assuming is the same crash by opening a print preview window in Chrome (using its wayland Ozone backend), using Sway 1.10.1 and wlroots 0.18.2 with the patch from https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4981 applied. Same “cairo_image_surface_create failed”, then:

(gdb) bt
(assert stuff omitted)
#5  0x00007f24feecd692 in __assert_fail
    (assertion=0x7f24ff8c3328 "box->x >= 0 && box->y >= 0 && box->x + box->width <= options->texture->width && box->y + box->height <= options->texture->height", file=0x7f24ff8c32e0 "render/pass.c", line=23, function=0x7f24ff8c3410 <__PRETTY_FUNCTION__.1> "wlr_render_pass_add_texture") at ./assert/assert.c:105
#6  0x00007f24ff80765d in wlr_render_pass_add_texture (render_pass=0x55cff2179200, options=0x7ffe85840170) at ../subprojects/wlroots/render/pass.c:23
#7  0x00007f24ff844e96 in scene_entry_render (entry=0x55cff2159cf8, data=0x7ffe85840440) at ../subprojects/wlroots/types/scene/wlr_scene.c:1270
#8  0x00007f24ff846af9 in wlr_scene_output_build_state (scene_output=0x55cff1afb5d0, state=0x7ffe85840580, options=0x7ffe85840600) at ../subprojects/wlroots/types/scene/wlr_scene.c:1959
#9  0x000055cfb3f91122 in output_repaint_timer_handler (data=0x55cff1aeabe0) at ../sway/desktop/output.c:285
#10 0x000055cfb3f9146d in handle_frame (listener=0x55cff1aead30, user_data=0x55cff1b0d4b0) at ../sway/desktop/output.c:373
#11 0x00007f24ff121b4c in wl_signal_emit_mutable () at /lib/x86_64-linux-gnu/libwayland-server.so.0
#12 0x00007f24ff83e10d in wlr_output_send_frame (output=0x55cff1b0d4b0) at ../subprojects/wlroots/types/output/output.c:753
#13 0x00007f24ff81e68b in handle_page_flip (fd=12, seq=488118, tv_sec=8164, tv_usec=155314, crtc_id=100, data=0x55cff21818d0) at ../subprojects/wlroots/backend/drm/drm.c:2100
#14 0x00007f24ff65fc47 in drmHandleEvent () at /lib/x86_64-linux-gnu/libdrm.so.2
#15 0x00007f24ff81e6de in handle_drm_event (fd=12, mask=1, data=0x55cff0a72000) at ../subprojects/wlroots/backend/drm/drm.c:2112
#16 0x00007f24ff123cf2 in wl_event_loop_dispatch () at /lib/x86_64-linux-gnu/libwayland-server.so.0
#17 0x00007f24ff121525 in wl_display_run () at /lib/x86_64-linux-gnu/libwayland-server.so.0
#18 0x000055cfb3f8d4c7 in server_run (server=0x55cfb400dce0 <server>) at ../sway/server.c:501
#19 0x000055cfb3f8bc33 in main (argc=1, argv=0x7ffe85841068) at ../sway/main.c:374

(gdb) f 6
...
(gdb) p *box
$1 = {x = 0, y = 0, width = 3820, height = 36}
(gdb) p *options->texture
$2 = {impl = 0x7f24ff908fe0 <texture_impl>, width = 374, height = 36, renderer = 0x55cff0c50f00}

(height matches, box width much larger than texture width).

I have a 3840x2400 output with scale factor 2, but this doesn’t obviously look like something scale-factor-related. My titlebars are (based on counting pixels in a screenshot) 52 pixels tall, but there’s a bunch of padding around the titlebar text so if there’s a texture not including that text a 36 pixel height for that seems plausible. (Also, options->dst_box has x=10, y=8, and width and height same as src_box: assuming that’s relative to the output that’d fit with it being titlebar text).

Applying the logging patch from https://github.com/swaywm/sway/issues/8194#issuecomment-2600936550 (on top of the other wlroots patch, it looks like the added logging still makes sense), that logging does not trigger.

Haven’t wrapped my head around what all this code does yet…

Looking at sway_text_node_set_max_width, there’s an update_source_box call before the render_backing_buffer call (here). render_backing_buffer contains its own update_source_box call here, which is paired with a wlr_scene_buffer_set_buffer call. Judging by that previous logged error, we’re exiting render_backing_buffer early (here).

Again, don’t know what this code does yet, but that seemed suspicious… I tried commenting out the update_source_box call before the render_backing_buffer call (reasoning that as long as render_backing_buffer doesn’t fail it’ll call update_source_box again anyway and at first glance that’d plausibly be early enough) and now I’m no longer crashing but I get a very horizontally stretched titlebar: it’s plausible the text is supposed to be 374 pixels (from the earlier coredump) wide, but it’s stretched horizontally to fill the entire titlebar. I also saw a similarly stretched titlebar briefly when starting Chrome.

So that’s not the right fix but hopefully that narrows it down a bit further… (I’ll look into this more if I find time)

I accidentally found a reliable reproducer: A massive window title triggers it, tested with both Firefox and Chromium. Here’s two PoC HTML files: black-bar.txt causes the title bar to only show a black bar, and doubling the title size (crash.txt) causes a crash.

Firefox may trigger this too:

#0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
#1  ? in __pthread_kill_internal (threadid=<optimized out>, signo=6) at pthread_kill.c:78
#2  ? in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3  ? in __GI_abort () at abort.c:79
#4  ? in __assert_fail_base
    (fmt=? "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=? "box->x >= 0 && box->y >= 0 && box->x + box->width <= options->texture->width && box->y + box->height <= options->texture->height", file=file@entry=? "render/pass.c", line=line@entry=23, function=function@entry=? <__PRETTY_FUNCTION__.1> "wlr_render_pass_add_texture") at assert.c:94
#5  ? in __assert_fail
    (assertion=? "box->x >= 0 && box->y >= 0 && box->x + box->width <= options->texture->width && box->y + box->height <= options->texture->height", file=? "render/pass.c", line=23, function=? <__PRETTY_FUNCTION__.1> "wlr_render_pass_add_texture") at assert.c:103
#6  ? in wlr_render_pass_add_texture (render_pass=?, options=?) at ../subprojects/wlroots/render/pass.c:23
#7  ? in scene_entry_render (entry=?, data=?) at ../subprojects/wlroots/types/scene/wlr_scene.c:1388
#8  ? in wlr_scene_output_build_state (scene_output=?, state=?, options=?) at ../subprojects/wlroots/types/scene/wlr_scene.c:2192
#9  ? in output_repaint_timer_handler (data=?) at ../sway/desktop/output.c:283
#10 ? in handle_frame (listener=?, user_data=?) at ../sway/desktop/output.c:355
#11 ? in wl_signal_emit_mutable (signal=<optimized out>, data=?) at ../wayland-1.23.1/src/wayland-server.c:2314
#12 ? in wlr_output_send_frame (output=?) at ../subprojects/wlroots/types/output/output.c:787
#13 ? in handle_page_flip (fd=10, seq=0, tv_sec=29181, tv_usec=482033, crtc_id=57, data=?) at ../subprojects/wlroots/backend/drm/drm.c:2001
#14 ? in drmHandleEvent (fd=10, evctx=?) at ../libdrm-2.4.123/xf86drmMode.c:1070
#15 ? in handle_drm_event (fd=10, mask=1, data=?) at ../subprojects/wlroots/backend/drm/drm.c:2013
#16 ? in wl_event_loop_dispatch (loop=?, timeout=<optimized out>, timeout@entry=-1) at ../wayland-1.23.1/src/event-loop.c:1105
#17 ? in wl_display_run (display=?) at ../wayland-1.23.1/src/wayland-server.c:1530
#18 ? in server_run (server=? <server>) at ../sway/server.c:508
#19 ? in main (argc=2, argv=?) at ../sway/main.c:373