brndnmtthws / conky

Light-weight system monitor for X, Wayland (sort of), and other things, too
https://conky.cc
GNU General Public License v3.0
7.17k stars 615 forks source link

[Bug]: segfault when zwlr_layer_shell_v1 not available on Wayland #1751

Closed brndnmtthws closed 7 months ago

brndnmtthws commented 7 months ago

What happened?

Conky segfaults when zwlr_layer_shell_v1 is not available, but it should handle this gracefully. At the moment we call zwlr_layer_shell_v1_get_layer_surface() before checking we have layer_shell:

https://github.com/brndnmtthws/conky/blob/98087f9fc49ba5b0b70aab20f55ced81cb9269bb/src/display-wayland.cc#L585-L587

Version

main

Which OS/distro are you seeing the problem on?

Ubuntu

Conky config

No response

Stack trace

Starting program: /home/ppsmol/conky/build/src/conky -c conkyrc
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1".
conky: drawing to single buffer
conky: invalid setting of type 'table'
[New Thread 0xfffff61fee60 (LWP 17344)]

Thread 1 "conky" received signal SIGSEGV, Segmentation fault.
0x0000fffff7a679d0 in wl_proxy_get_version () from /lib/aarch64-linux-gnu/libwayland-client.so.0
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /home/ppsmol/conky/build/src/conky -c conkyrc
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1".
conky: drawing to single buffer
conky: invalid setting of type 'table'
[New Thread 0xfffff61fee60 (LWP 17357)]

Thread 1 "conky" received signal SIGSEGV, Segmentation fault.
0x0000fffff7a679d0 in wl_proxy_get_version () from /lib/aarch64-linux-gnu/libwayland-client.so.0
(gdb) bt full
#0  0x0000fffff7a679d0 in wl_proxy_get_version () at /lib/aarch64-linux-gnu/libwayland-client.so.0
#1  0x0000aaaaaab1910c in zwlr_layer_shell_v1_get_layer_surface(zwlr_layer_shell_v1*, wl_surface*, wl_output*, unsigned int, char const*)
    (zwlr_layer_shell_v1=0x0, surface=0xaaaaaad462b0, output=0x0, layer=1, namespace_=0xaaaaaab7cf1f "conky_namespace")
    at src/wlr-layer-shell-client-protocol.h:230
        id = 0xfffffffff0d8
#2  0x0000aaaaaab18d34 in conky::display_output_wayland::initialize() (this=0xaaaaaad0b718 <conky::(anonymous namespace)::wayland_output>)
    at /home/ppsmol/conky/src/display-wayland.cc:585
        surface = 0xaaaaaad462b0
        listener = {capabilities = 0xffffffffeb00, name = 0xaaaaaaad02c4 <std::__1::vector<conky::display_output_base*, std::__1::allocator<conky::display_output_base*> >::push_back(conky::display_output_base* const&)+88>}
#3  0x0000aaaaaab0b3b8 in conky::initialize_display_outputs() () at /home/ppsmol/conky/src/display-output.cc:137
        output = 0xaaaaaad0b718 <conky::(anonymous namespace)::wayland_output>
        __range1 = @0xffffffffebe0: {__begin_ = 0xaaaaaad410f0, __end_ = 0xaaaaaad41120, __end_cap_ = {<std::__1::__compressed_pair_elem<conky::display_output_base**, 0, false>> = {__value_ = 0xaaaaaad41120}, <std::__1::__compressed_pair_elem<std::__1::allocator<conky::display_output_base*>, 1, true>> = {<std::__1::allocator<conky::display_output_base*>> = {<std::__1::__non_trivial_if<true, std::__1::allocator<conky::display_output_base*> >> = {<No data fields>}, <No data fields>}, <No data fields>}, <No data fields>}}
        __begin1 = {__i = 0xaaaaaad410f0}
        __end1 = {__i = 0xaaaaaad41120}
        outputs = {__begin_ = 0xaaaaaad410f0, __end_ = 0xaaaaaad41120, __end_cap_ = {<std::__1::__compressed_pair_elem<conky::display_output_base**, 0, false>> = {__value_ = 0xaaaaaad41120}, <std::__1::__compressed_pair_elem<std::__1::allocator<conky::display_output_base*>, 1, true>> = {<std::__1::allocator<conky::display_output_base*>> = {<std::__1::__non_trivial_if<true, std::__1::allocator<conky::display_output_base*> >> = {<No data fields>}, <No data fields>}, <No data fields>}, <No data fields>}}
        graphical_count = 0
#4  0x0000aaaaaaaca208 in initialisation(int, char**) (argc=3, argv=0xfffffffff0d8) at /home/ppsmol/conky/src/conky.cc:2259
--Type <RET> for more, q to quit, c to continue without paging--c
        act = {__sigaction_handler = {sa_handler = 0x0, sa_sigaction = 0x0}, sa_mask = {__val = {0 <repeats 16 times>}}, sa_flags = 0, sa_restorer = 0x0}
        oact = {__sigaction_handler = {sa_handler = 0x0, sa_sigaction = 0x0}, sa_mask = {__val = {0 <repeats 16 times>}}, sa_flags = 0, sa_restorer = 0x0}
#5  0x0000aaaaaaac1ecc in main(int, char**) (argc=3, argv=0xfffffffff0d8) at /home/ppsmol/conky/src/main.cc:362
        e = @0xfffff7fce494: {_vptr$exception = 0xad4287e0aa0003f0}
        e = @0xfffffffff070: {<std::runtime_error> = {<No data fields>}, <No data fields>}
        e = @0xfffff7fce494: {<std::runtime_error> = {<No data fields>}, <No data fields>}
        e = @0xfffffffff060: {<std::runtime_error> = {<No data fields>}, <No data fields>}
(gdb) quit
A debugging session is active.

        Inferior 1 [process 17356] will be killed.

Quit anyway? (y or n) y

Relevant log output

No response

brndnmtthws commented 7 months ago

cc @Caellian