~emersion/grim#85: 
Segmentation fault

I've hyprland. It used to work. It segfaults now.

❯ grim
Segmentation fault (core dumped)
Status
REPORTED
Submitter
~k0li
Assigned to
No-one
Submitted
2 years ago
Updated
2 years ago
Labels
No labels applied.

~k0li 2 years ago

GDB

Program received signal SIGSEGV, Segmentation fault.
_pixman_image_validate (image=0x0) at ../pixman-0.42.2/pixman/pixman-image.c:549
549	   if (image->common.dirty)

~k0li 2 years ago

bah, it's working again after restarting the compositor

~emersion 2 years ago

Can you obtain a stack trace?

~k0li 2 years ago

Yeah, it is crashing again.

I'm no expert with meson nor with gdb, but here you are:

❯ gdb ./build/grim
GNU gdb (GDB) 12.1
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./build/grim...
(gdb) run
Starting program: /mnt/dataint/data/progetti_altrui/grim/build/grim 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
_pixman_image_validate (image=0x0) at ../pixman-0.42.2/pixman/pixman-image.c:549
549	   if (image->common.dirty)
(gdb) backtrace
#0  _pixman_image_validate (image=0x0) at ../pixman-0.42.2/pixman/pixman-image.c:549
<a href="/~emersion/grim/1" title="~emersion/grim#1: Orbital screenshooter protocol support">#1</a>  pixman_image_composite32 (op=PIXMAN_OP_SRC, src=0x555555569780, mask=0x0, dest=0x0, src_x=0, src_y=0, mask_x=0, 
    mask_y=0, dest_x=0, dest_y=0, width=1920, height=1080) at ../pixman-0.42.2/pixman/pixman.c:588
<a href="/~emersion/grim/2" title="~emersion/grim#2: Use the xdg-output protocol to get output layout">#2</a>  0x000055555555adb9 in render (state=0x7fffffffdf40, geometry=0x55555556b920, scale=1) at ../render.c:246
<a href="/~emersion/grim/3" title="~emersion/grim#3: Use xdg-output to get outputs names">#3</a>  0x0000555555559984 in main (argc=1, argv=0x7fffffffe0e8) at ../main.c:559

~k0li 2 years ago

I have no idea nor why it is putting HTML tags in it nor why it saves my edit but don't publish it

~k0li 2 years ago

Oh I see, it thinks #1 #2 and #3 refers to issues

~mstoeckl 2 years ago

The following line of the backtrace suggests that the pixman_image_t * common_image is being set to NULL at render.c#L134. This might be caused by grim receiving incorrect parameters about the outputs from hyprland. Could you please report the Wayland debug log output? (i.e, run WAYLAND_DEBUG=1 grim, and provide the logs that are printed.)

pixman_image_composite32 (op=PIXMAN_OP_SRC, src=0x555555569780, mask=0x0, dest=0x0, src_x=0, src_y=0, mask_x=0,

~k0li 2 years ago*

eDP-1 is my laptop screen, which is black as I use an external monitor with the lid closed

❯ WAYLAND_DEBUG=1 ./build/grim
[ 760942.628]  -> wl_display@1.get_registry(new id wl_registry@2)
[ 760942.651]  -> wl_display@1.sync(new id wl_callback@3)
[ 760942.845] wl_display@1.delete_id(3)
[ 760942.854] wl_registry@2.global(1, "wl_shm", 1)
[ 760942.862]  -> wl_registry@2.bind(1, "wl_shm", 1, new id [unknown]@4)
[ 760942.869] wl_registry@2.global(2, "wl_drm", 2)
[ 760942.875] wl_registry@2.global(3, "zwp_linux_dmabuf_v1", 4)
[ 760942.879] wl_registry@2.global(4, "wl_compositor", 5)
[ 760942.884] wl_registry@2.global(5, "wl_subcompositor", 1)
[ 760942.887] wl_registry@2.global(6, "wl_data_device_manager", 3)
[ 760942.892] wl_registry@2.global(7, "zwlr_export_dmabuf_manager_v1", 1)
[ 760942.898] wl_registry@2.global(8, "zwlr_screencopy_manager_v1", 3)
[ 760942.904]  -> wl_registry@2.bind(8, "zwlr_screencopy_manager_v1", 1, new id [unknown]@5)
[ 760942.910] wl_registry@2.global(9, "zwlr_data_control_manager_v1", 2)
[ 760942.915] wl_registry@2.global(10, "zwlr_gamma_control_manager_v1", 1)
[ 760942.921] wl_registry@2.global(11, "zwp_primary_selection_device_manager_v1", 1)
[ 760942.927] wl_registry@2.global(12, "wp_viewporter", 1)
[ 760942.932] wl_registry@2.global(13, "zwlr_output_power_manager_v1", 1)
[ 760942.937] wl_registry@2.global(14, "xdg_wm_base", 5)
[ 760942.942] wl_registry@2.global(15, "wl_seat", 8)
[ 760942.947] wl_registry@2.global(16, "wp_presentation", 1)
[ 760942.952] wl_registry@2.global(17, "org_kde_kwin_idle", 1)
[ 760942.957] wl_registry@2.global(18, "zwlr_layer_shell_v1", 4)
[ 760942.962] wl_registry@2.global(19, "org_kde_kwin_server_decoration_manager", 1)
[ 760942.967] wl_registry@2.global(20, "zxdg_decoration_manager_v1", 1)
[ 760942.972] wl_registry@2.global(21, "zxdg_output_manager_v1", 3)
[ 760942.979]  -> wl_registry@2.bind(21, "zxdg_output_manager_v1", 2, new id [unknown]@6)
[ 760942.984] wl_registry@2.global(22, "zwlr_output_manager_v1", 4)
[ 760942.990] wl_registry@2.global(23, "zwlr_input_inhibit_manager_v1", 1)
[ 760942.995] wl_registry@2.global(24, "zwp_keyboard_shortcuts_inhibit_manager_v1", 1)
[ 760943.000] wl_registry@2.global(25, "zext_workspace_manager_v1", 1)
[ 760943.006] wl_registry@2.global(26, "zwp_pointer_constraints_v1", 1)
[ 760943.011] wl_registry@2.global(27, "zwp_relative_pointer_manager_v1", 1)
[ 760943.016] wl_registry@2.global(28, "zwp_virtual_keyboard_manager_v1", 1)
[ 760943.021] wl_registry@2.global(29, "zwlr_virtual_pointer_manager_v1", 2)
[ 760943.029] wl_registry@2.global(30, "zwlr_foreign_toplevel_manager_v1", 3)
[ 760943.034] wl_registry@2.global(31, "wp_drm_lease_device_v1", 1)
[ 760943.040] wl_registry@2.global(32, "zwp_tablet_manager_v2", 1)
[ 760943.045] wl_registry@2.global(33, "zwp_idle_inhibit_manager_v1", 1)
[ 760943.050] wl_registry@2.global(34, "zxdg_exporter_v1", 1)
[ 760943.054] wl_registry@2.global(35, "zxdg_importer_v1", 1)
[ 760943.059] wl_registry@2.global(36, "zxdg_exporter_v2", 1)
[ 760943.064] wl_registry@2.global(37, "zxdg_importer_v2", 1)
[ 760943.068] wl_registry@2.global(38, "zwp_pointer_gestures_v1", 3)
[ 760943.073] wl_registry@2.global(39, "zwp_text_input_manager_v3", 1)
[ 760943.093] wl_registry@2.global(40, "zwp_input_method_manager_v2", 1)
[ 760943.100] wl_registry@2.global(41, "xdg_activation_v1", 1)
[ 760943.107] wl_registry@2.global(42, "xwayland_shell_v1", 1)
[ 760943.114] wl_registry@2.global(43, "hyprland_toplevel_export_manager_v1", 2)
[ 760943.121] wl_registry@2.global(44, "wp_fractional_scale_manager_v1", 1)
[ 760943.128] wl_registry@2.global(45, "wl_output", 4)
[ 760943.137]  -> wl_registry@2.bind(45, "wl_output", 3, new id [unknown]@7)
[ 760943.144] wl_callback@3.done(144)
[ 760943.151]  -> zxdg_output_manager_v1@6.get_xdg_output(new id zxdg_output_v1@3, wl_output@7)
[ 760943.159]  -> wl_display@1.sync(new id wl_callback@8)
[ 760943.418] wl_display@1.delete_id(8)
[ 760943.439] wl_output@7.geometry(0, 0, 340, 190, 0, "AU Optronics", "0xAF90", 0)
[ 760943.448] wl_output@7.mode(1, 1920, 1080, 144149)
[ 760943.454] wl_output@7.scale(1)
[ 760943.459] wl_output@7.done()
[ 760943.464] zxdg_output_v1@3.name("eDP-1")
[ 760943.469] zxdg_output_v1@3.description("AU Optronics 0xAF90 (eDP-1)")
[ 760943.474] zxdg_output_v1@3.logical_position(0, 0)
[ 760943.480] zxdg_output_v1@3.logical_size(1920, 1080)
[ 760943.485] zxdg_output_v1@3.done()
[ 760943.491] wl_callback@8.done(144)
[ 760943.499]  -> zwlr_screencopy_manager_v1@5.capture_output(new id zwlr_screencopy_frame_v1@8, 0, wl_output@7)
[ 760951.395] zwlr_screencopy_frame_v1@8.buffer(1, 1920, 1080, 7680)
[ 760951.575]  -> wl_shm@4.create_pool(new id wl_shm_pool@9, fd 5, 8294400)
[ 760951.587]  -> wl_shm_pool@9.create_buffer(new id wl_buffer@10, 0, 1920, 1080, 7680, 1)
[ 760951.592]  -> wl_shm_pool@9.destroy()
[ 760951.599]  -> zwlr_screencopy_frame_v1@8.copy(wl_buffer@10)
[ 760977.131] wl_display@1.delete_id(9)
[ 760977.156] zwlr_screencopy_frame_v1@8.flags(0)
[ 760977.160] zwlr_screencopy_frame_v1@8.ready(0, 24762, 856222206)
[ 761126.456]  -> zwlr_screencopy_frame_v1@8.destroy()
[ 761126.722]  -> wl_buffer@10.destroy()
[ 761126.725]  -> zxdg_output_v1@3.destroy()
[ 761126.727]  -> wl_output@7.release()
[ 761126.729]  -> zwlr_screencopy_manager_v1@5.destroy()
[ 761126.730]  -> zxdg_output_manager_v1@6.destroy()

~k0li 2 years ago

Actually the external monitor mirrors the laptop one and is not even seen:

❯ hyprctl monitors
Monitor eDP-1 (ID 0):
	1920x1080@144.149002 at 0x0
	description: AU Optronics 0xAF90 (eDP-1)
	make: AU Optronics
	model: 0xAF90
	serial: 
	active workspace: 2 (2)
	reserved: 0 30 0 0
	scale: 1.00
	transform: 0
	focused: yes
	dpmsStatus: 1

~mstoeckl 2 years ago*

Sorry, I should have been more precise: could you please post the WAYLAND_DEBUG=1 grim logs from an unsuccessful run, where grim segfaults? {I am assuming grim did not crash here, since the last lines of the log shows cleanup requests, like zxdg_output_manager_v1@6.destroy(), that only run after grim has saved an image.)

Alternatively, inside gdb, run bt full to get a stack trace that (assuming a debug build) prints the state of all variables on the stack.

~k0li 2 years ago

Yes it is working again.

I'll post it if and when it segfaults again.

~k0li 2 years ago

❯ WAYLAND_DEBUG=1 ./build/grim
[3521736.836]  -> wl_display@1.get_registry(new id wl_registry@2)
[3521736.872]  -> wl_display@1.sync(new id wl_callback@3)
[3521738.785] wl_display@1.delete_id(3)
[3521738.797] wl_registry@2.global(1, "wl_shm", 1)
[3521738.802]  -> wl_registry@2.bind(1, "wl_shm", 1, new id [unknown]@4)
[3521738.805] wl_registry@2.global(2, "wl_drm", 2)
[3521738.807] wl_registry@2.global(3, "zwp_linux_dmabuf_v1", 4)
[3521738.808] wl_registry@2.global(4, "wl_compositor", 5)
[3521738.809] wl_registry@2.global(5, "wl_subcompositor", 1)
[3521738.811] wl_registry@2.global(6, "wl_data_device_manager", 3)
[3521738.812] wl_registry@2.global(7, "zwlr_export_dmabuf_manager_v1", 1)
[3521738.813] wl_registry@2.global(8, "zwlr_screencopy_manager_v1", 3)
[3521738.814]  -> wl_registry@2.bind(8, "zwlr_screencopy_manager_v1", 1, new id [unknown]@5)
[3521738.816] wl_registry@2.global(9, "zwlr_data_control_manager_v1", 2)
[3521738.817] wl_registry@2.global(10, "zwlr_gamma_control_manager_v1", 1)
[3521738.819] wl_registry@2.global(11, "zwp_primary_selection_device_manager_v1", 1)
[3521738.820] wl_registry@2.global(12, "wp_viewporter", 1)
[3521738.822] wl_registry@2.global(13, "zwlr_output_power_manager_v1", 1)
[3521738.823] wl_registry@2.global(14, "xdg_wm_base", 5)
[3521738.824] wl_registry@2.global(15, "wl_seat", 8)
[3521738.826] wl_registry@2.global(16, "wp_presentation", 1)
[3521738.827] wl_registry@2.global(17, "org_kde_kwin_idle", 1)
[3521738.829] wl_registry@2.global(18, "zwlr_layer_shell_v1", 4)
[3521738.831] wl_registry@2.global(19, "org_kde_kwin_server_decoration_manager", 1)
[3521738.832] wl_registry@2.global(20, "zxdg_decoration_manager_v1", 1)
[3521738.835] wl_registry@2.global(21, "zxdg_output_manager_v1", 3)
[3521738.837]  -> wl_registry@2.bind(21, "zxdg_output_manager_v1", 2, new id [unknown]@6)
[3521738.840] wl_registry@2.global(22, "zwlr_output_manager_v1", 4)
[3521738.842] wl_registry@2.global(23, "zwlr_input_inhibit_manager_v1", 1)
[3521738.843] wl_registry@2.global(24, "zwp_keyboard_shortcuts_inhibit_manager_v1", 1)
[3521738.845] wl_registry@2.global(25, "zext_workspace_manager_v1", 1)
[3521738.846] wl_registry@2.global(26, "zwp_pointer_constraints_v1", 1)
[3521738.848] wl_registry@2.global(27, "zwp_relative_pointer_manager_v1", 1)
[3521738.850] wl_registry@2.global(28, "zwp_virtual_keyboard_manager_v1", 1)
[3521738.851] wl_registry@2.global(29, "zwlr_virtual_pointer_manager_v1", 2)
[3521738.852] wl_registry@2.global(30, "zwlr_foreign_toplevel_manager_v1", 3)
[3521738.854] wl_registry@2.global(31, "wp_drm_lease_device_v1", 1)
[3521738.855] wl_registry@2.global(32, "zwp_tablet_manager_v2", 1)
[3521738.857] wl_registry@2.global(33, "zwp_idle_inhibit_manager_v1", 1)
[3521738.858] wl_registry@2.global(34, "zxdg_exporter_v1", 1)
[3521738.860] wl_registry@2.global(35, "zxdg_importer_v1", 1)
[3521738.862] wl_registry@2.global(36, "zxdg_exporter_v2", 1)
[3521738.864] wl_registry@2.global(37, "zxdg_importer_v2", 1)
[3521738.865] wl_registry@2.global(38, "zwp_pointer_gestures_v1", 3)
[3521738.866] wl_registry@2.global(39, "zwp_text_input_manager_v3", 1)
[3521738.868] wl_registry@2.global(40, "zwp_input_method_manager_v2", 1)
[3521738.870] wl_registry@2.global(41, "xdg_activation_v1", 1)
[3521738.871] wl_registry@2.global(42, "xwayland_shell_v1", 1)
[3521738.873] wl_registry@2.global(43, "hyprland_toplevel_export_manager_v1", 2)
[3521738.874] wl_registry@2.global(44, "wp_fractional_scale_manager_v1", 1)
[3521738.876] wl_registry@2.global(45, "wl_output", 4)
[3521738.879]  -> wl_registry@2.bind(45, "wl_output", 3, new id [unknown]@7)
[3521738.882] wl_registry@2.global(47, "wl_output", 4)
[3521738.884]  -> wl_registry@2.bind(47, "wl_output", 3, new id [unknown]@8)
[3521738.886] wl_callback@3.done(27093)
[3521738.889]  -> zxdg_output_manager_v1@6.get_xdg_output(new id zxdg_output_v1@3, wl_output@8)
[3521738.892]  -> zxdg_output_manager_v1@6.get_xdg_output(new id zxdg_output_v1@9, wl_output@7)
[3521738.894]  -> wl_display@1.sync(new id wl_callback@10)
[3521739.040] wl_display@1.delete_id(10)
[3521739.048] wl_output@7.geometry(0, 0, 340, 190, 0, "AU Optronics", "0xAF90", 0)
[3521739.051] wl_output@7.mode(1, 1920, 1080, 144149)
[3521739.053] wl_output@7.scale(1)
[3521739.054] wl_output@7.done()
[3521739.055] wl_output@8.geometry(0, 0, 520, 290, 0, "Samsung Electric Company", "C24F390", 0)
[3521739.058] wl_output@8.mode(1, 1920, 1080, 60000)
[3521739.059] wl_output@8.scale(1)
[3521739.060] wl_output@8.done()
[3521739.061] zxdg_output_v1@3.name("HDMI-A-1")
[3521739.063] zxdg_output_v1@3.description("Samsung Electric Company C24F390 H4LT305839 (HDMI-A-1)")
[3521739.064] zxdg_output_v1@3.logical_position(-1337420, -1337420)
[3521739.066] zxdg_output_v1@3.logical_size(1920, 1080)
[3521739.067] zxdg_output_v1@3.done()
[3521739.068] zxdg_output_v1@9.name("eDP-1")
[3521739.069] zxdg_output_v1@9.description("AU Optronics 0xAF90 (eDP-1)")
[3521739.070] zxdg_output_v1@9.logical_position(0, 0)
[3521739.072] zxdg_output_v1@9.logical_size(1920, 1080)
[3521739.073] zxdg_output_v1@9.done()
[3521739.074] wl_callback@10.done(27093)
[3521739.076]  -> zwlr_screencopy_manager_v1@5.capture_output(new id zwlr_screencopy_frame_v1@10, 0, wl_output@8)
[3521739.079]  -> zwlr_screencopy_manager_v1@5.capture_output(new id zwlr_screencopy_frame_v1@11, 0, wl_output@7)
[3521739.193] zwlr_screencopy_frame_v1@10.buffer(1, 1920, 1080, 7680)
[3521739.234]  -> wl_shm@4.create_pool(new id wl_shm_pool@12, fd 5, 8294400)
[3521739.237]  -> wl_shm_pool@12.create_buffer(new id wl_buffer@13, 0, 1920, 1080, 7680, 1)
[3521739.240]  -> wl_shm_pool@12.destroy()
[3521739.243]  -> zwlr_screencopy_frame_v1@10.copy(wl_buffer@13)
[3521739.245] zwlr_screencopy_frame_v1@11.buffer(1, 1920, 1080, 7680)
[3521739.252]  -> wl_shm@4.create_pool(new id wl_shm_pool@14, fd 6, 8294400)
[3521739.257]  -> wl_shm_pool@14.create_buffer(new id wl_buffer@15, 0, 1920, 1080, 7680, 1)
[3521739.259]  -> wl_shm_pool@14.destroy()
[3521739.262]  -> zwlr_screencopy_frame_v1@11.copy(wl_buffer@15)
[3521748.051] wl_display@1.delete_id(12)
[3521748.067] wl_display@1.delete_id(14)
[3521748.068] zwlr_screencopy_frame_v1@10.flags(0)
[3521748.069] zwlr_screencopy_frame_v1@10.ready(0, 67347, 220569615)
[3521756.264] zwlr_screencopy_frame_v1@11.flags(0)
[3521756.278] zwlr_screencopy_frame_v1@11.ready(0, 67347, 230962780)
Segmentation fault (core dumped)

~k0li 2 years ago

❯ gdb ./build/grim
GNU gdb (GDB) 12.1
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./build/grim...
(gdb) run
Starting program: [ABRIDGED]/build/grim 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
_pixman_image_validate (image=0x0) at ../pixman-0.42.2/pixman/pixman-image.c:549
549	   if (image->common.dirty)
(gdb) bt full
#0  _pixman_image_validate (image=0x0)
    at ../pixman-0.42.2/pixman/pixman-image.c:549
No locals.
<a href="/~emersion/grim/1" title="~emersion/grim#1: Orbital screenshooter protocol support">#1</a>  pixman_image_composite32 (op=PIXMAN_OP_SRC, 
    src=0x555555569780, mask=0x0, dest=0x0, src_x=0, 
    src_y=0, mask_x=0, mask_y=0, dest_x=0, dest_y=0, 
    width=1920, height=1080)
    at ../pixman-0.42.2/pixman/pixman.c:588
        src_format = <optimized out>
        mask_format = <optimized out>
        dest_format = <optimized out>
        region = {extents = {x1 = 65536, y1 = 0, 
            x2 = 58326784, y2 = 1869924022}, 
          data = 0x3ff0000000000000}
        extents = {x1 = 125829120, y1 = 0, x2 = 70778880, 
          y2 = 0}
        imp = 0x7ffff7e4cd71 <pixman_transform_point+65>
        func = 0x7ffff7ffd000 <_rtld_global>
        info = {op = PIXMAN_OP_CLEAR, src_image = 0x0, 
          mask_image = 0x3ff0000000000000, dest_image = 0x0, 
          src_x = 0, src_y = 0, mask_x = 0, mask_y = 0, 
          dest_x = 0, dest_y = 1072693248, width = 58326784, 
          height = 1869924022, src_flags = 0, 
          mask_flags = 1920, dest_flags = 4158971327}
        pbox = <optimized out>
        n = 21845
<a href="/~emersion/grim/2" title="~emersion/grim#2: Use the xdg-output protocol to get output layout">#2</a>  0x000055555555adb9 in render (state=0x7fffffffdf10, 
    geometry=0x55555556b920, scale=1) at ../render.c:246
        x_scale = 1
        output_image = 0x555555569780
        out2com = {m = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}}
        composite_dest = {x = 0, y = 0, width = 1920, 
--Type <RET> for more, q to quit, c to continue without paging--
          height = 1080}
        com2out = {m = {{1, -0, 0}, {-0, 1, -0}, {0, -0, 1}}}
        other_output = 0x7fffffffdf20
        op = PIXMAN_OP_SRC
        output_height = 1080
        raw_output_height = 1080
        output_flipped_x = 1
        grid_aligned = true
        c2o_fixedpt = {matrix = {{65536, 0, 0}, {0, 65536, 
              0}, {0, 0, 65536}}}
        output_x = 0
        output_flipped_y = 1
        y_scale = 1
        overlapping = false
        buffer = 0x55555556b0a0
        pixman_fmt = PIXMAN_x8r8g8b8
        output_y = 0
        output_width = 1920
        raw_output_width = 1920
        common_image = 0x0
        output = 0x5555555692d0
<a href="/~emersion/grim/3" title="~emersion/grim#3: Use xdg-output to get outputs names">#3</a>  0x0000555555559984 in main (argc=1, argv=0x7fffffffe0b8)
    at ../main.c:559
        scale = 1
        use_greatest_scale = true
        geometry = 0x55555556b920
        geometry_output = 0x0
        output_filetype = GRIM_FILETYPE_PNG
        jpeg_quality = 80
        png_level = 6
        with_cursor = false
        opt = -1
--Type <RET> for more, q to quit, c to continue without paging--
        output_filename = 0x7fffffffdf50 "20230201_23h18m48s_grim.png"
        output_filepath = 0x555555563740 "[ABRIDGED]/Pictures/20230201_23h18m48s_grim.png"
        tmp = "20230201_23h18m48s_grim.png\000\000\000\000\000\240k\321\367\377\177\000\000%\234\267\367\377\177\000\000\000\000\000\000\000\000\000\000@+VUUU\000"
        state = {display = 0x555555563780, 
          registry = 0x5555555638d0, shm = 0x55555556b490, 
          xdg_output_manager = 0x555555569150, 
          screencopy_manager = 0x55555556b650, outputs = {
            prev = 0x5555555698a8, next = 0x5555555692e8}, 
          n_done = 2}
        n_pending = 2
        output = 0x7fffffffdf20
        done = true
        image = 0x7ffff7d16c00 <main_arena+96>
        file = 0x280
        ret = 0
        output_tmp = 0x29

~mstoeckl 2 years ago*

zxdg_output_v1@3.logical_position(-1337420, -1337420)

This explains the crash. If I understand the code correctly, grim tries to render onto an image which contains both HDMI-A-1 and eDP-1 at the logical positions specified. Since the compositor claims that HDMI-A-1 is very far to the the left, and very far up, the smallest rectangle containing the two has size 1337420+1920 = 1339340 by 1338500, and any image of that size requires much more memory to store than is available; thus creating common_image fails, and grim crashes later on.

~k0li 2 years ago

so we should ...... ?

~emersion 2 years ago

We should probably exit with a clear error instead of segfaulting.

~k0li 2 years ago

and in order to don't have the error and take the screenshot we should .... ?

~emersion 2 years ago

We shouldn't support this case, no. You need to reconfigure your outputs to have a more reasonable layout.

~k0li 2 years ago

I configured my external monitor HDMI-A-1 to mirror my laptop monitor, and in fact Hyprland only reports 1 monitor:

❯ hyprctl monitors
Monitor eDP-1 (ID 0):
	1920x1080@144.149002 at 0x0
	description: AU Optronics 0xAF90 (eDP-1)
	make: AU Optronics
	model: 0xAF90
	serial: 
	active workspace: 3 (3)
	reserved: 0 30 0 0
	scale: 1.00
	transform: 0
	focused: yes
	dpmsStatus: 1

Can you tell me how you figured out there was an external monitor too?

~k0li 2 years ago

This is the relevant config in my hyprland.conf file:

# MONITORS
# See https://wiki.hyprland.org/Configuring/Monitors/
monitor=eDP-1,preferred,auto,1
monitor=HDMI-A-1,preferred,auto,1,mirror,eDP-1

~emersion 2 years ago

The compositor advertises it via the Wayland protocol. wayland-info should show it too.

~k0li 2 years ago

So I paste the following and the link to this issue in the hyprland issue report?

interface: 'zxdg_output_manager_v1',                     version:  3, name: 21
	xdg_output_v1
		output: 47
		name: 'HDMI-A-1'
		description: 'Samsung Electric Company C24F390 H4LT305839 (HDMI-A-1)'
		logical_x: -1337420, logical_y: -1337420
		logical_width: 1920, logical_height: 1080
	xdg_output_v1
		output: 45
		name: 'eDP-1'
		description: 'AU Optronics 0xAF90 (eDP-1)'
		logical_x: 0, logical_y: 0
		logical_width: 1920, logical_height: 1080

~emersion 2 years ago

Yes, please report this as a bug to the hyprland devs.

~k0li 2 years ago

I don't think you should try to capture both monitors if the external one is a mirror?

Why you don't capture just one of them?

~emersion 2 years ago*

We have no way to detect that one is a mirror of the other.

~k0li 2 years ago

But when it works, because most of the time it works, I only capture one monitor.

I don't capture an image file with two monitors side-by-side that display the same thing.

I don't understand how that is possible, if we always captured both of them?

~emersion 2 years ago

If both monitor's positions overlap, grim will overwrite one monitor's content with the other.

If both monitor's position and size are exactly the same, grim might be able to detect and avoid copies. But that's not the case in the log you gave above.

~k0li 2 years ago

So you are telling me that when it works, the two monitors have the same logical position and logical size?

So now Hyprland decided it was proper to change the logical position of one of them for some reason?

~emersion 2 years ago

I don't know. Would need some WAYLAND_DEBUG=1 logs collected when it works to tell.

~k0li 2 years ago

Here it works:

❯ WAYLAND_DEBUG=1 ./build/grim
[2836790.541]  -> wl_display@1.get_registry(new id wl_registry@2)
[2836790.569]  -> wl_display@1.sync(new id wl_callback@3)
[2836792.627] wl_display@1.delete_id(3)
[2836792.651] wl_registry@2.global(1, "wl_shm", 1)
[2836792.663]  -> wl_registry@2.bind(1, "wl_shm", 1, new id [unknown]@4)
[2836792.669] wl_registry@2.global(2, "wl_drm", 2)
[2836792.673] wl_registry@2.global(3, "zwp_linux_dmabuf_v1", 4)
[2836792.676] wl_registry@2.global(4, "wl_compositor", 5)
[2836792.679] wl_registry@2.global(5, "wl_subcompositor", 1)
[2836792.683] wl_registry@2.global(6, "wl_data_device_manager", 3)
[2836792.686] wl_registry@2.global(7, "zwlr_export_dmabuf_manager_v1", 1)
[2836792.689] wl_registry@2.global(8, "zwlr_screencopy_manager_v1", 3)
[2836792.694]  -> wl_registry@2.bind(8, "zwlr_screencopy_manager_v1", 1, new id [unknown]@5)
[2836792.698] wl_registry@2.global(9, "zwlr_data_control_manager_v1", 2)
[2836792.701] wl_registry@2.global(10, "zwlr_gamma_control_manager_v1", 1)
[2836792.704] wl_registry@2.global(11, "zwp_primary_selection_device_manager_v1", 1)
[2836792.708] wl_registry@2.global(12, "wp_viewporter", 1)
[2836792.711] wl_registry@2.global(13, "zwlr_output_power_manager_v1", 1)
[2836792.715] wl_registry@2.global(14, "xdg_wm_base", 5)
[2836792.718] wl_registry@2.global(15, "wl_seat", 8)
[2836792.722] wl_registry@2.global(16, "wp_presentation", 1)
[2836792.725] wl_registry@2.global(17, "org_kde_kwin_idle", 1)
[2836792.729] wl_registry@2.global(18, "zwlr_layer_shell_v1", 4)
[2836792.732] wl_registry@2.global(19, "org_kde_kwin_server_decoration_manager", 1)
[2836792.736] wl_registry@2.global(20, "zxdg_decoration_manager_v1", 1)
[2836792.739] wl_registry@2.global(21, "zxdg_output_manager_v1", 3)
[2836792.743]  -> wl_registry@2.bind(21, "zxdg_output_manager_v1", 2, new id [unknown]@6)
[2836792.747] wl_registry@2.global(22, "zwlr_output_manager_v1", 4)
[2836792.750] wl_registry@2.global(23, "zwlr_input_inhibit_manager_v1", 1)
[2836792.758] wl_registry@2.global(24, "zwp_keyboard_shortcuts_inhibit_manager_v1", 1)
[2836792.762] wl_registry@2.global(25, "zext_workspace_manager_v1", 1)
[2836792.768] wl_registry@2.global(26, "zwp_pointer_constraints_v1", 1)
[2836792.774] wl_registry@2.global(27, "zwp_relative_pointer_manager_v1", 1)
[2836792.781] wl_registry@2.global(28, "zwp_virtual_keyboard_manager_v1", 1)
[2836792.788] wl_registry@2.global(29, "zwlr_virtual_pointer_manager_v1", 2)
[2836792.793] wl_registry@2.global(30, "zwlr_foreign_toplevel_manager_v1", 3)
[2836792.799] wl_registry@2.global(31, "wp_drm_lease_device_v1", 1)
[2836792.806] wl_registry@2.global(32, "zwp_tablet_manager_v2", 1)
[2836792.812] wl_registry@2.global(33, "zwp_idle_inhibit_manager_v1", 1)
[2836792.819] wl_registry@2.global(34, "zxdg_exporter_v1", 1)
[2836792.826] wl_registry@2.global(35, "zxdg_importer_v1", 1)
[2836792.833] wl_registry@2.global(36, "zxdg_exporter_v2", 1)
[2836792.839] wl_registry@2.global(37, "zxdg_importer_v2", 1)
[2836792.846] wl_registry@2.global(38, "zwp_pointer_gestures_v1", 3)
[2836792.852] wl_registry@2.global(39, "zwp_text_input_manager_v3", 1)
[2836792.858] wl_registry@2.global(40, "zwp_input_method_manager_v2", 1)
[2836792.865] wl_registry@2.global(41, "xdg_activation_v1", 1)
[2836792.871] wl_registry@2.global(42, "xwayland_shell_v1", 1)
[2836792.877] wl_registry@2.global(43, "hyprland_toplevel_export_manager_v1", 2)
[2836792.880] wl_registry@2.global(44, "wp_fractional_scale_manager_v1", 1)
[2836792.886] wl_registry@2.global(45, "wl_output", 4)
[2836792.896]  -> wl_registry@2.bind(45, "wl_output", 3, new id [unknown]@7)
[2836792.904] wl_callback@3.done(152)
[2836792.913]  -> zxdg_output_manager_v1@6.get_xdg_output(new id zxdg_output_v1@3, wl_output@7)
[2836792.923]  -> wl_display@1.sync(new id wl_callback@8)
[2836796.265] wl_display@1.delete_id(8)
[2836796.294] wl_output@7.geometry(0, 0, 340, 190, 0, "AU Optronics", "0xAF90", 0)
[2836796.304] wl_output@7.mode(1, 1920, 1080, 144149)
[2836796.309] wl_output@7.scale(1)
[2836796.314] wl_output@7.done()
[2836796.317] zxdg_output_v1@3.name("eDP-1")
[2836796.322] zxdg_output_v1@3.description("AU Optronics 0xAF90 (eDP-1)")
[2836796.326] zxdg_output_v1@3.logical_position(0, 0)
[2836796.335] zxdg_output_v1@3.logical_size(1920, 1080)
[2836796.340] zxdg_output_v1@3.done()
[2836796.344] wl_callback@8.done(152)
[2836796.354]  -> zwlr_screencopy_manager_v1@5.capture_output(new id zwlr_screencopy_frame_v1@8, 0, wl_output@7)
[2836796.557] zwlr_screencopy_frame_v1@8.buffer(1, 1920, 1080, 7680)
[2836796.669]  -> wl_shm@4.create_pool(new id wl_shm_pool@9, fd 5, 8294400)
[2836796.683]  -> wl_shm_pool@9.create_buffer(new id wl_buffer@10, 0, 1920, 1080, 7680, 1)
[2836796.690]  -> wl_shm_pool@9.destroy()
[2836796.699]  -> zwlr_screencopy_frame_v1@8.copy(wl_buffer@10)
[2836814.205] wl_display@1.delete_id(9)
[2836814.226] zwlr_screencopy_frame_v1@8.flags(0)
[2836814.230] zwlr_screencopy_frame_v1@8.ready(0, 70948, 700431766)
[2837066.194]  -> zwlr_screencopy_frame_v1@8.destroy()
[2837066.491]  -> wl_buffer@10.destroy()
[2837066.499]  -> zxdg_output_v1@3.destroy()
[2837066.501]  -> wl_output@7.release()
[2837066.503]  -> zwlr_screencopy_manager_v1@5.destroy()
[2837066.505]  -> zxdg_output_manager_v1@6.destroy()

~k0li 2 years ago

But now the compositor is not advertising the external monitor anymore?

interface: 'zxdg_output_manager_v1',                     version:  3, name: 21
	xdg_output_v1
		output: 45
		name: 'eDP-1'
		description: 'AU Optronics 0xAF90 (eDP-1)'
		logical_x: 0, logical_y: 0
		logical_width: 1920, logical_height: 1080
interface: 'wl_output',                                  version:  4, name: 45
	name: eDP-1
	description: AU Optronics 0xAF90 (eDP-1)
	x: 0, y: 0, scale: 1,
	physical_width: 340 mm, physical_height: 190 mm,
	make: 'AU Optronics', model: '0xAF90',
	subpixel_orientation: unknown, output_transform: normal,
	mode:
		width: 1920 px, height: 1080 px, refresh: 144.149 Hz,
		flags: current

So when it worked you were not given the external monitor.

~k0li 2 years ago

Can I have grim take screenshots from only one monitor, so as to work around this?

The bug report on Hyprland is stuck