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.27k stars 620 forks source link

[Bug]: segmentation fault upon modification of conkyrc. (Regression?) #1908

Closed LinuxOnTheDesktop closed 5 months ago

LinuxOnTheDesktop commented 6 months ago

What happened?

I had Conky running (via the Bash script that I use always) and I modified my conkyrc. I saw this:

108971 Segmentation fault (core dumped) conky -c "${conk_path[conkyRc]}"

I am on Linux Mint Cinnamon.

I compiled from source using the latest code from git.

Previously I was using a Conky that I had compiled from source, from git, approximately a week ago - and I think that then I did not have the problem. I believe also that there was a bug report about this or a similar problem - a closed report - but I cannot find that report at present.

Version

1.21.0-pre-6bf383cf

Which OS/distro are you seeing the problem on?

Linux (other)

Conky config

No response

Stack trace

# Er . .
$ gdb
(gdb) run -c <full-path-of-my-conkyRC>
[. . .]
No executable file specified
[. . .]
(gdb) run conky -c <full-path-of-my-conkyRC>
[. . .]
No executable file specified

Relevant log output

No response

Caellian commented 6 months ago

You didn't start gdb with conky executable nor attached it later. Do gdb /bin/conky (if that's the path to conky on your system). Then, instead of run -c <full-path-of-my-conkyRC> actually replace <full-path-of-my-conkyRC> with a path to (one of) your conky configuration file(s).

LinuxOnTheDesktop commented 6 months ago

@Caellian

Do gdb /bin/conky (if that's the path to conky on your system)

Understood and my mistake. Sorry.

Then, instead of run -c [etc.]

I am unsure I understand. Obviously I will replace the pseudo-path that is within the angle-brackets.

I am not on the affected computer right now. But that does all me to add the following. The earlier version of Conky on which I do not have the problem advertises itself (within my Conky itself) as 1.19.8_pre.

LinuxOnTheDesktop commented 6 months ago

Stack trace

Thread 1 "conky" received signal SIGSEGV, Segmentation fault.
conky::rect<int>::at (index=0, this=0x0) at /home/<redacted>/git/conky/conky/src/geometry.h:452
452         return this->get_x();
(gdb) bt full
#0  conky::rect<int>::at (index=0, this=0x0) at /home/<redacted>/git/conky/conky/src/geometry.h:452
No locals.
#1  conky::_priv_geom::_member_access<conky::rect<int>, int>::operator int (this=0x5555557accf8 <window+184>)
    at /home/<redacted>/git/conky/conky/src/geometry.h:62
No locals.
#2  x11_init_window (l=..., own=<optimised out>) at /home/<redacted>/git/conky/conky/src/x11.cc:598
        attrs = {background_pixmap = 1, background_pixel = 0, border_pixmap = 0, border_pixel = 0, bit_gravity = 0, win_gravity = 0, 
          backing_store = 2, backing_planes = 0, backing_pixel = 0, save_under = 0, event_mask = 163852, do_not_propagate_mask = 0, 
          override_redirect = 0, colormap = 85983233, cursor = 0}
        wmHint = {flags = 93823560581426, input = 1343720183, initial_state = 1716254802, icon_pixmap = 7371240303965604599, 
          icon_window = 0, icon_x = 1885956979, icon_y = 1734439007, icon_mask = 140737337389669, window_group = 35}
        xa = <optimised out>
        hints = <optimised out>
        depth = 32
        flags = <optimised out>
        visual = 0x55555580a2f0
        classHint = {res_name = 0x7fffffffd200 "conky", res_class = 0x7fffffffd200 "conky"}
        class_name = "conky"
        b = 7
        input_mask = <optimised out>
        xinput_ok = <optimised out>
#3  0x000055555561834e in priv::own_window_setting::lua_setter (this=0x5555557ad3a0 <own_window>, l=..., init=<optimised out>)
    at /home/<redacted>/git/conky/conky/src/gui.cc:93
        s = {L = 0x5555557ca120, n = 4}
#4  0x00005555555d8def in conky::priv::config_setting_base::process_setting (l=..., init=<optimised out>)
    at /home/<redacted>/git/conky/conky/src/setting.cc:197
        s = {L = 0x5555557ca120, n = 3}
        ptr = <optimised out>
#5  0x00005555555da237 in conky::set_config_settings (l=...) at /home/<redacted>/git/conky/conky/src/setting.cc:284
        i = 0x5555557ad3a0 <own_window>
        __for_range = std::vector of length 130, capacity 130 = {0x5555557acb60 <display_name[abi:cxx11]>, 0x5555557acae0 <out_to_x>, 
          0x5555557acaa0 <use_xft>, 0x5555557ad320 <font>, 0x5555557acfa0 <font_template[abi:cxx11]>, 
          0x5555557acff8 <font_template[abi:cxx11]+88>, 0x5555557ad050 <font_template[abi:cxx11]+176>, 
          0x5555557ad0a8 <font_template[abi:cxx11]+264>, 0x5555557ad100 <font_template[abi:cxx11]+352>, 
          0x5555557ad158 <font_template[abi:cxx11]+440>, 0x5555557ad1b0 <font_template[abi:cxx11]+528>, 
--Type <RET> for more, q to quit, c to continue without paging--
          0x5555557ad208 <font_template[abi:cxx11]+616>, 0x5555557ad260 <font_template[abi:cxx11]+704>, 
          0x5555557ad2b8 <font_template[abi:cxx11]+792>, 0x55555566d5a0 <color>, 0x55555566d5d8 <color+56>, 
          0x55555566d610 <color+112>, 0x55555566d648 <color+168>, 0x55555566d680 <color+224>, 0x55555566d6b8 <color+280>, 
          0x55555566d6f0 <color+336>, 0x55555566d728 <color+392>, 0x55555566d760 <color+448>, 0x55555566d798 <color+504>, 
          0x55555566d560 <default_color>, 0x5555557ad720 <default_shade_color>, 0x5555557ad6e0 <default_outline_color>, 
          0x5555557ad6a0 <border_inner_margin>, 0x5555557ad660 <border_outer_margin>, 0x5555557ad620 <border_width>, 
          0x5555557ad760 <text_alignment>, 0x5555557acb20 <head_index>, 0x5555557ad460 <set_transparent>, 
          0x5555557ad520 <own_window_class[abi:cxx11]>, 0x5555557ad5c0 <own_window_title[abi:cxx11]>, 
          0x5555557ad580 <own_window_type>, 0x5555557ad4e0 <own_window_hints>, 0x5555557ad3e0 <own_window_argb_value>, 
          0x5555557ad420 <use_argb_visual>, 0x5555557ad4a0 <background_colour>, 0x5555557ad3a0 <own_window>, 
          0x5555557aca20 <use_xdbe>, 0x5555557ae0a0 <imlib_cache_size>, 0x5555557ae100 <imlib_draw_blended>, 
          0x55555566d900 <no_buffers>, 0x55555566d8a0 <bar_fill[abi:cxx11]>, 0x55555566d840 <bar_unfill[abi:cxx11]>, 
          0x55555566d7e0 <github_token[abi:cxx11]>, 0x55555566ea80 <disable_auto_reload>, 0x55555566ea20 <use_spacer>, 
          0x55555566e9e0 <short_units>, 0x55555566e9a0 <format_human_readable>, 0x55555566e600 <units_spacer[abi:cxx11]>, 
          0x55555566e5c0 <out_to_stdout>, 0x55555566e580 <out_to_stderr>, 0x55555566e500 <update_interval>, 
          0x55555566e4a0 <update_interval_on_battery>, 0x55555566e440 <detect_battery[abi:cxx11]>, 
          0x55555566e400 <music_player_interval>, 0x55555566e940 <max_text_width>, 0x55555566e900 <stuff_in_uppercase>, 
          0x55555566e8c0 <stuff_in_lowercase>, 0x55555566e860 <total_run_times>, 0x55555566e820 <fork_to_background>, 
          0x55555566de60 <cpu_avg_samples>, 0x55555566de20 <net_avg_samples>, 0x55555566dde0 <diskio_avg_samples>, 
          0x55555566dda0 <show_graph_scale>, 0x55555566dd60 <show_graph_range>, 0x55555566e7e0 <graph_gradient_mode>, 
          0x55555566dca0 <gap_x>, 0x55555566dc60 <gap_y>, 0x55555566dc20 <draw_borders>, 0x55555566dbe0 <draw_graph_borders>, 
          0x55555566dba0 <stippled_borders>, 0x55555566db60 <draw_shades>, 0x55555566db20 <draw_outline>, 
          0x55555566dac0 <minimum_height>, 0x55555566da80 <minimum_width>, 0x55555566da40 <maximum_width>, 
          0x55555566da00 <utf8_mode>, 0x55555566d9c0 <max_user_text>, 0x55555566d980 <text_buffer_size>, 
          0x55555566e7a0 <pad_percents>, 0x5555556785c0 <current_mail_spool>, 0x555555678680 <(anonymous namespace)::imap>, 
          0x555555678620 <(anonymous namespace)::pop3>, 0x5555557a6280 <if_up_strictness>, 
          0x5555557a62c0 <(anonymous namespace)::_template>, 0x5555557a6318 <(anonymous namespace)::_template+88>, 
          0x5555557a6370 <(anonymous namespace)::_template+176>, 0x5555557a63c8 <(anonymous namespace)::_template+264>, 
          0x5555557a6420 <(anonymous namespace)::_template+352>, 0x5555557a6478 <(anonymous namespace)::_template+440>, 
          0x5555557a64d0 <(anonymous namespace)::_template+528>, 0x5555557a6528 <(anonymous namespace)::_template+616>, 
          0x5555557a6580 <(anonymous namespace)::_template+704>, 0x5555557a65d8 <(anonymous namespace)::_template+792>, 
          0x5555557a69a0 <(anonymous namespace)::default_bar_width>, 0x5555557a6960 <(anonymous namespace)::default_bar_height>, 
          0x5555557a6920 <(anonymous namespace)::default_graph_width>, 0x5555557a68e0 <(anonymous namespace)::default_graph_height>, 
          0x5555557a68a0 <(anonymous namespace)::default_gauge_width>, 0x5555557a6860 <(anonymous namespace)::default_gauge_height>, 
          0x5555557a6820 <(anonymous namespace)::store_graph_data_explicitly>, 
--Type <RET> for more, q to quit, c to continue without paging--
          0x5555557a67c0 <(anonymous namespace)::console_graph_ticks>, 0x5555557a6a60 <output_unit>, 
          0x5555557a6aa0 <times_in_seconds>, 0x5555557a6b40 <top_name_width>, 0x5555557a6b00 <top_name_verbose>, 
          0x5555557a7c80 <extra_newline>, 0x5555557a7d60 <overwrite_file>, 0x5555557a7d00 <append_file>, 
          0x5555557a8040 <(anonymous namespace)::lua_load>, 0x5555557a7fe0 <(anonymous namespace)::lua_startup_hook>, 
          0x5555557a7f80 <(anonymous namespace)::lua_shutdown_hook>, 0x5555557a7f20 <(anonymous namespace)::lua_draw_hook_pre>, 
          0x5555557a7ec0 <(anonymous namespace)::lua_draw_hook_post>, 0x5555557a7e60 <(anonymous namespace)::lua_mouse_hook>, 
          0x5555557ac6e0 <top_cpu_separate>, 0x5555557ac860 <(anonymous namespace)::mpd_port>, 
          0x5555557ac800 <(anonymous namespace)::mpd_host>, 0x5555557ac7a0 <(anonymous namespace)::mpd_password>, 
          0x5555557ac8a0 <max_port_monitor_connections>, 0x5555557ac9c0 <(anonymous namespace)::xftalpha>, 
          0x5555557aca60 <forced_redraw>, 0x5555557ae040 <hddtemp_host>, 0x5555557adfe0 <hddtemp_port>, 
          0x5555557ae140 <imlib_cache_flush_interval>, 0x5555557ae6c0 <out_to_ncurses>}
        __for_begin = <optimised out>
        __for_end = <optimised out>
        v = std::vector of length 130, capacity 130 = {0x5555557acb60 <display_name[abi:cxx11]>, 0x5555557acae0 <out_to_x>, 
          0x5555557acaa0 <use_xft>, 0x5555557ad320 <font>, 0x5555557acfa0 <font_template[abi:cxx11]>, 
          0x5555557acff8 <font_template[abi:cxx11]+88>, 0x5555557ad050 <font_template[abi:cxx11]+176>, 
          0x5555557ad0a8 <font_template[abi:cxx11]+264>, 0x5555557ad100 <font_template[abi:cxx11]+352>, 
          0x5555557ad158 <font_template[abi:cxx11]+440>, 0x5555557ad1b0 <font_template[abi:cxx11]+528>, 
          0x5555557ad208 <font_template[abi:cxx11]+616>, 0x5555557ad260 <font_template[abi:cxx11]+704>, 
          0x5555557ad2b8 <font_template[abi:cxx11]+792>, 0x55555566d5a0 <color>, 0x55555566d5d8 <color+56>, 
          0x55555566d610 <color+112>, 0x55555566d648 <color+168>, 0x55555566d680 <color+224>, 0x55555566d6b8 <color+280>, 
          0x55555566d6f0 <color+336>, 0x55555566d728 <color+392>, 0x55555566d760 <color+448>, 0x55555566d798 <color+504>, 
          0x55555566d560 <default_color>, 0x5555557ad720 <default_shade_color>, 0x5555557ad6e0 <default_outline_color>, 
          0x5555557ad6a0 <border_inner_margin>, 0x5555557ad660 <border_outer_margin>, 0x5555557ad620 <border_width>, 
          0x5555557ad760 <text_alignment>, 0x5555557acb20 <head_index>, 0x5555557ad460 <set_transparent>, 
          0x5555557ad520 <own_window_class[abi:cxx11]>, 0x5555557ad5c0 <own_window_title[abi:cxx11]>, 
          0x5555557ad580 <own_window_type>, 0x5555557ad4e0 <own_window_hints>, 0x5555557ad3e0 <own_window_argb_value>, 
          0x5555557ad420 <use_argb_visual>, 0x5555557ad4a0 <background_colour>, 0x5555557ad3a0 <own_window>, 
          0x5555557aca20 <use_xdbe>, 0x5555557ae0a0 <imlib_cache_size>, 0x5555557ae100 <imlib_draw_blended>, 
          0x55555566d900 <no_buffers>, 0x55555566d8a0 <bar_fill[abi:cxx11]>, 0x55555566d840 <bar_unfill[abi:cxx11]>, 
          0x55555566d7e0 <github_token[abi:cxx11]>, 0x55555566ea80 <disable_auto_reload>, 0x55555566ea20 <use_spacer>, 
          0x55555566e9e0 <short_units>, 0x55555566e9a0 <format_human_readable>, 0x55555566e600 <units_spacer[abi:cxx11]>, 
          0x55555566e5c0 <out_to_stdout>, 0x55555566e580 <out_to_stderr>, 0x55555566e500 <update_interval>, 
          0x55555566e4a0 <update_interval_on_battery>, 0x55555566e440 <detect_battery[abi:cxx11]>, 
          0x55555566e400 <music_player_interval>, 0x55555566e940 <max_text_width>, 0x55555566e900 <stuff_in_uppercase>, 
--Type <RET> for more, q to quit, c to continue without paging--
          0x55555566e8c0 <stuff_in_lowercase>, 0x55555566e860 <total_run_times>, 0x55555566e820 <fork_to_background>, 
          0x55555566de60 <cpu_avg_samples>, 0x55555566de20 <net_avg_samples>, 0x55555566dde0 <diskio_avg_samples>, 
          0x55555566dda0 <show_graph_scale>, 0x55555566dd60 <show_graph_range>, 0x55555566e7e0 <graph_gradient_mode>, 
          0x55555566dca0 <gap_x>, 0x55555566dc60 <gap_y>, 0x55555566dc20 <draw_borders>, 0x55555566dbe0 <draw_graph_borders>, 
          0x55555566dba0 <stippled_borders>, 0x55555566db60 <draw_shades>, 0x55555566db20 <draw_outline>, 
          0x55555566dac0 <minimum_height>, 0x55555566da80 <minimum_width>, 0x55555566da40 <maximum_width>, 
          0x55555566da00 <utf8_mode>, 0x55555566d9c0 <max_user_text>, 0x55555566d980 <text_buffer_size>, 
          0x55555566e7a0 <pad_percents>, 0x5555556785c0 <current_mail_spool>, 0x555555678680 <(anonymous namespace)::imap>, 
          0x555555678620 <(anonymous namespace)::pop3>, 0x5555557a6280 <if_up_strictness>, 
          0x5555557a62c0 <(anonymous namespace)::_template>, 0x5555557a6318 <(anonymous namespace)::_template+88>, 
          0x5555557a6370 <(anonymous namespace)::_template+176>, 0x5555557a63c8 <(anonymous namespace)::_template+264>, 
          0x5555557a6420 <(anonymous namespace)::_template+352>, 0x5555557a6478 <(anonymous namespace)::_template+440>, 
          0x5555557a64d0 <(anonymous namespace)::_template+528>, 0x5555557a6528 <(anonymous namespace)::_template+616>, 
          0x5555557a6580 <(anonymous namespace)::_template+704>, 0x5555557a65d8 <(anonymous namespace)::_template+792>, 
          0x5555557a69a0 <(anonymous namespace)::default_bar_width>, 0x5555557a6960 <(anonymous namespace)::default_bar_height>, 
          0x5555557a6920 <(anonymous namespace)::default_graph_width>, 0x5555557a68e0 <(anonymous namespace)::default_graph_height>, 
          0x5555557a68a0 <(anonymous namespace)::default_gauge_width>, 0x5555557a6860 <(anonymous namespace)::default_gauge_height>, 
          0x5555557a6820 <(anonymous namespace)::store_graph_data_explicitly>, 
          0x5555557a67c0 <(anonymous namespace)::console_graph_ticks>, 0x5555557a6a60 <output_unit>, 
          0x5555557a6aa0 <times_in_seconds>, 0x5555557a6b40 <top_name_width>, 0x5555557a6b00 <top_name_verbose>, 
          0x5555557a7c80 <extra_newline>, 0x5555557a7d60 <overwrite_file>, 0x5555557a7d00 <append_file>, 
          0x5555557a8040 <(anonymous namespace)::lua_load>, 0x5555557a7fe0 <(anonymous namespace)::lua_startup_hook>, 
          0x5555557a7f80 <(anonymous namespace)::lua_shutdown_hook>, 0x5555557a7f20 <(anonymous namespace)::lua_draw_hook_pre>, 
          0x5555557a7ec0 <(anonymous namespace)::lua_draw_hook_post>, 0x5555557a7e60 <(anonymous namespace)::lua_mouse_hook>, 
          0x5555557ac6e0 <top_cpu_separate>, 0x5555557ac860 <(anonymous namespace)::mpd_port>, 
          0x5555557ac800 <(anonymous namespace)::mpd_host>, 0x5555557ac7a0 <(anonymous namespace)::mpd_password>, 
          0x5555557ac8a0 <max_port_monitor_connections>, 0x5555557ac9c0 <(anonymous namespace)::xftalpha>, 
          0x5555557aca60 <forced_redraw>, 0x5555557ae040 <hddtemp_host>, 0x5555557adfe0 <hddtemp_port>, 
          0x5555557ae140 <imlib_cache_flush_interval>, 0x5555557ae6c0 <out_to_ncurses>}
        s = {L = 0x5555557ca120, n = 0}
#6  0x0000555555598bbc in initialisation (argc=3, argv=0x7fffffffdbf8) at /usr/include/c++/11/bits/unique_ptr.h:173
        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}
--Type <RET> for more, q to quit, c to continue without paging--
#7  0x00005555555992c3 in reload_config () at /home/<redacted>/git/conky/conky/src/conky.cc:1869
        sb = <optimised out>
        sb = <optimised out>
#8  reload_config () at /home/<redacted>/git/conky/conky/src/conky.cc:1854
        sb = {st_dev = 2051, st_ino = 262150, st_nlink = 1, st_mode = 33270, st_uid = 1000, st_gid = 0, __pad0 = 0, st_rdev = 0, 
          st_size = 8935, st_blksize = 4096, st_blocks = 24, st_atim = {tv_sec = 1715462339, tv_nsec = 515011907}, st_mtim = {
            tv_sec = 1715547820, tv_nsec = 107078527}, st_ctim = {tv_sec = 1715547820, tv_nsec = 107078527}, __glibc_reserved = {0, 
            0, 0}}
#9  0x000055555559e54f in main_loop () at /home/<redacted>/git/conky/conky/src/conky.cc:1819
        ev = 0x7fffffffd780
        len = 16
        idx = 0
        descriptors = {fds_bits = {8, 0 <repeats 15 times>}}
        time_to_wait = {tv_sec = 0, tv_usec = 0}
        terminate = 0
        t = <optimised out>
        inotify_config_wd = 13
        inotify_buff = "\r\000\000\000\002", '\000' <repeats 12 times>, "\327\377\377\377\177\000\000\340\177zUUU\000\000@\225fUUU\000\000\n\206cUUU\000\000p\331\377\377\377\177\000\000\311\310]UUU\000\000\320\327\377\377\377\177", '\000' <repeats 11 times>, "\367\177UUU\000\000\340^\206UUU\000\000@\225fUUU\000\000\000x\020\200\357~\210\204`\334fUUU\000\000\320\330\377\377\377\177\000\000\000\347fUUU\000\000\360\246}UUU\000\000@\225fUUU\000\000\245\217YUUU\000\000\320\330\377\377\377\177\000\000p\331\377\377\377\177\000\000\001\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\a\000\000\000\000\000\000\000"...
#10 0x000055555558657a in main (argc=3, argv=0x7fffffffdbf8) at /home/<redacted>/git/conky/conky/src/main.cc:371
No locals.
Caellian commented 6 months ago

Caused by PR introducing geometry primitives #1862.

The cause is _member_access having invalid pointer to Container (rect<int>).

Line that crashes:

window.window = XCreateWindow(display, window.root, window.geometry.x,
                              window.geometry.y, b, b, 0, depth,
                              InputOutput, visual, flags, &attrs);

on window.geometry.x because this from x _member_access is invalid.

My hunch is this gets moved and so the pointer is invalid.

Reproduced by reloading the config.

Currently trying the following to fix this: update those pointers on move and move assignment.

Caellian commented 6 months ago

So the problem is that I tried being too clever with the dark arts of metaprogramming and missed that assignment to nested rect member (pos in this case) makes it impossible to update rect _member_access.

The previously proposed fix would require additional metadata at which point the rect struct would store more metadata than actual data, just to provide a bit more convenient syntax. For stored members the metadata can't be erased so the benefit is not worth the cost.

So I'm removing _member_access.

Caellian commented 6 months ago

@LinuxOnTheDesktop I was able to reproduce and can't anymore after fix/geometry-accessors. Can you confirm it's fixed?

LinuxOnTheDesktop commented 6 months ago

I am afraid that the problem is not fixed. Here are some details.

I used git to obtain a version of conky that advertises itself as 1.21.0-pre-6bf383cf343. With that version modifying conkyrc crashes conky with a 'segmentation fault'.

Caellian commented 6 months ago

Clone the branch I linked with git clone -b fix/geometry-accessors https://github.com/brndnmtthws/conky.git

LinuxOnTheDesktop commented 6 months ago

Right. I think I've switched branch. (I'm not great at git.) Conky now advertises itself as 1.21.0-pre-6bf383cf.

I seem to have the same problem as before. For, the terminal reports that the config file was modified, and that consequently it is being reloaded, but then I still get a segementation fault. I can, later, supply another stack trace.

Caellian commented 6 months ago

Alright, do let me know, because I was able to replicate and I believe the changes that got merged fixed the problem. If you're still seeing conky::_priv_geom::_member_access in the stack trace that means you're starting a wrong binary because _member_access was removed.

In any case, paste the new stack trace and I'll check it out.

LinuxOnTheDesktop commented 5 months ago

The latest iteration of version 1.21.1 (the iteration advertised here) seems to fix this problem. Great!

EDITED.