Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: conky HTTP server hangs forever, cannot serve requests #1649

Open
ctrlcctrlv opened this issue Oct 14, 2023 · 2 comments
Open

[Bug]: conky HTTP server hangs forever, cannot serve requests #1649

ctrlcctrlv opened this issue Oct 14, 2023 · 2 comments
Labels
bug Bug report or bug fix PR display: http Issue or PR related to HTTP backend lua Issue or PR related to Lua code

Comments

@ctrlcctrlv
Copy link

What happened?

the built-in HTTP server is unreliable and hangs forever, deadlock inside liblua.so

Version

conky 1.19.7_pre compiled 2023-10-14 for Linux x86_64

Which OS/distro are you seeing the problem on?

Arch Linux

Conky config

conky.config = {
    alignment = 'top_right',
    background = true,
    border_width = 1,
    cpu_avg_samples = 2,
    default_color = 'white',
    default_outline_color = 'white',
    default_shade_color = 'white',
    double_buffer = true,
    draw_borders = false,
    draw_graph_borders = true,
    draw_outline = false,
    draw_shades = false,
    extra_newline = false,
    font = 'Unifont:size=12',
    gap_x = 60,
    gap_y = 60,
    minimum_height = 5,
    minimum_width = 8,
    net_avg_samples = 2,
    no_buffers = false,
    out_to_console = false,
    out_to_ncurses = false,
    out_to_stderr = false,
    out_to_x = true,
    out_to_http = true,
    http_port = 1234,
    http_refresh = true,
    if_up_strictness = 'address',
    own_window = true,
    own_window_class = 'conky',
    -- put conky above xfdesktop but below all other windows
    own_window_type = 'normal',
    own_window_transparent = false,
    own_window_argb_visual = true,
    own_window_argb_value = 128,
    own_window_hints = 'undecorated,below,sticky,skip_taskbar,skip_pager',
    show_graph_range = false,
    show_graph_scale = false,
    stippled_borders = 0,
    update_interval = 5.5,
    uppercase = false,
    use_spacer = 'none',
    use_xft = true,
}

function fs_hr(line, last_mount)
    if not last_mount then
        return
    end
    if not table then
        return
    end
    -- If the mount has a different prefix dir than the last mount, then
    -- print a horizontal rule.
    local last_prefix = last_mount:match('^(.+)/')
    local prefix = line:match('^(.+)/')
    return last_prefix ~= prefix
end

-- get zfs mounts
function get_zfs_mounts()
    local mounts = {}
    local last_mount = '/'
    local f = io.popen([[awk '$3=="zfs"{print $2}' /proc/mounts|sort]])
    table.insert(mounts, '${hr}')
    for line in f:lines() do
        if fs_hr(line, last_mount, mounts) then
            table.insert(mounts, "${hr}")
        end
        last_mount = line
        table.insert(mounts, line)
    end
    f:close()
    table.insert(mounts, '${hr}')
    return mounts
end

conky_info = [[
${color grey}Info:$color ${scroll 64 Conky $conky_version - $sysname $nodename $kernel $machine}
$hr
${color grey}Uptime:$color $uptime
${color grey}Frequency (in GHz):$color $freq_g
${color grey}RAM Usage:$color $mem/$memmax - $memperc% ${membar 4}
${color grey}Swap Usage:$color $swap/$swapmax - $swapperc% ${swapbar 4}
${color grey}CPU Usage:$color $cpu% ${cpubar 4}
${color grey}Processes:$color $processes  ${color grey}Running:$color $running_processes
$hr
]]

conky_fs = [[
${color grey}File systems:
 / $color${fs_used /}/${fs_size /} ${fs_bar 6 /}
]]

conky.net = 'eth1'
conky_net = [[
${goto 0}${color grey}Networking:
${goto 0}Up:$color ${upspeed "eth1"} ${color grey} - Down:$color ${downspeed "eth1"}
${goto 0}Total Up:$color ${totalup "eth1"} ${color grey} - Total Down:$color ${totaldown "eth1"}
]]

conky_ps = [[
${color grey}Name              PID     CPU%   MEM%
${color lightgrey} ${top name 1} ${top pid 1} ${top cpu 1} ${top mem 1}
${color lightgrey} ${top name 2} ${top pid 2} ${top cpu 2} ${top mem 2}
${color lightgrey} ${top name 3} ${top pid 3} ${top cpu 3} ${top mem 3}
${color lightgrey} ${top name 4} ${top pid 4} ${top cpu 4} ${top mem 4}
]]


for _, mount in ipairs(get_zfs_mounts()) do
    if mount:sub(1, 1) ~= '/' then
        conky_fs = conky_fs .. mount .. '\n'
    else
        conky_fs = conky_fs .. [[${color grey} ]] .. mount .. [[ $color${fs_used ]] .. mount .. [[}/${fs_size ]] .. mount .. [[} ${fs_bar 6 ]] .. mount .. [[}
]]
    end
end

conky.text = conky_info .. conky_fs .. conky_ps .. conky_net

Stack trace

++
#0  0x00007f7800616554 in ?? () from /usr/lib/liblua.so.5.4
#1  0x00007f7800617194 in ?? () from /usr/lib/liblua.so.5.4
#2  0x00007f7800611574 in ?? () from /usr/lib/liblua.so.5.4
#3  0x00007f7800630f34 in ?? () from /usr/lib/liblua.so.5.4
#4  0x00007f78006172ce in lua_pcallk () from /usr/lib/liblua.so.5.4
#5  0x000055c94e0c8688 in lua::state::call (this=0x55c94f99d040, nargs=nargs@entry=2, nresults=nresults@entry=1, errfunc=errfunc@entry=0)
    at /usr/include/c++/13.2.1/bits/shared_ptr_base.h:1665
#6  0x000055c94e0c88d2 in lua::state::gettable (this=<optimized out>, index=<optimized out>) at /home/fred/.cache/yay/conky-git/src/conky/src/luamm.cc:348
#7  0x000055c94e0c8914 in lua::state::getfield (this=<optimized out>, index=<optimized out>, k=<optimized out>) at /home/fred/.cache/yay/conky-git/src/conky/src/luamm.cc:327
#8  0x000055c94e0cce0d in conky::config_setting_template<double>::get (l=..., this=<optimized out>) at /home/fred/.cache/yay/conky-git/src/conky/src/setting.hh:219
#9  conky::display_output_http::begin_draw_text (this=<optimized out>) at /home/fred/.cache/yay/conky-git/src/conky/src/display-http.cc:176
#10 0x000055c94e08cbda in draw_text () at /home/fred/.cache/yay/conky-git/src/conky/src/conky.cc:1560
#11 0x000055c94e08d65f in draw_stuff () at /home/fred/.cache/yay/conky-git/src/conky/src/conky.cc:1638
#12 0x000055c94e0d1335 in conky::display_output_x11::main_loop_wait (this=<optimized out>, t=<optimized out>) at /home/fred/.cache/yay/conky-git/src/conky/src/display-x11.cc:575
#13 0x000055c94e08f172 in main_loop () at /home/fred/.cache/yay/conky-git/src/conky/src/conky.cc:1734
#14 0x000055c94e08069d in main (argc=1, argv=0x7ffc8c0c5068) at /home/fred/.cache/yay/conky-git/src/conky/src/main.cc:355

Relevant log output

No response

@ctrlcctrlv ctrlcctrlv added bug Bug report or bug fix PR triage Issue that hasn't been verified labels Oct 14, 2023
@ctrlcctrlv
Copy link
Author

this also causes conky auto conf reload to fail because it gets stuck on trying to tear down the server, it hangs on MHD cleanup—

Using host libthread_db library "/usr/lib/libthread_db.so.1".
0x00007f77ffca74ae in ?? () from /usr/lib/libc.so.6
(gdb) bt
#0  0x00007f77ffca74ae in ?? () from /usr/lib/libc.so.6
#1  0x00007f77ffcac5f3 in ?? () from /usr/lib/libc.so.6
#2  0x00007f78008c012f in MHD_stop_daemon () from /usr/lib/libmicrohttpd.so.12
#3  0x000055c94e0ce09d in conky::out_to_http_setting::cleanup (this=<optimized out>, l=...)
    at /home/fred/.cache/yay/conky-git/src/conky/src/display-http.cc:108
#4  0x000055c94e0d4d25 in conky::cleanup_config_settings (l=...) at /home/fred/.cache/yay/conky-git/src/conky/src/setting.cc:312
#5  0x000055c94e08757e in clean_up () at /usr/include/c++/13.2.1/bits/unique_ptr.h:453
#6  0x000055c94e08a672 in reload_config () at /home/fred/.cache/yay/conky-git/src/conky/src/conky.cc:1853
#7  reload_config () at /home/fred/.cache/yay/conky-git/src/conky/src/conky.cc:1843
#8  0x000055c94e08f3f2 in main_loop () at /home/fred/.cache/yay/conky-git/src/conky/src/conky.cc:1808
#9  0x000055c94e08069d in main (argc=1, argv=0x7ffc8c0c5068) at /home/fred/.cache/yay/conky-git/src/conky/src/main.cc:355
#3  0x000055c94e0ce09d in conky::out_to_http_setting::cleanup (this=<optimized out>, l=...)
    at /home/fred/.cache/yay/conky-git/src/conky/src/display-http.cc:108
108	      MHD_stop_daemon(httpd);
(gdb) frame 4
#4  0x000055c94e0d4d25 in conky::cleanup_config_settings (l=...) at /home/fred/.cache/yay/conky-git/src/conky/src/setting.cc:312
312	    v[i - 1]->cleanup(l);

@ctrlcctrlv
Copy link
Author

@brndnmtthws i don't quite understand why you chose to implement it how you did, why not do it all in lua?

@Caellian Caellian added lua Issue or PR related to Lua code display: http Issue or PR related to HTTP backend and removed triage Issue that hasn't been verified labels Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug report or bug fix PR display: http Issue or PR related to HTTP backend lua Issue or PR related to Lua code
Projects
None yet
Development

No branches or pull requests

2 participants