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

SIGSEGV (Address boundary error) when trying to use Cairo #447

Closed Targuinia closed 6 years ago

Targuinia commented 6 years ago

If I try to use Cairo in a .lua file, it immediately crashes.

$ conky
conky: desktop window (228) is root window
conky: window type - desktop
conky: drawing to created window (0x3000002)
conky: drawing to double buffer
fish: “conky” terminated by signal SIGSEGV (Address boundary error)

I am using the conky-lua-nv package from the AUR.

conky 1.10.6_pre compiled Thu Jan  4 01:26:25 CET 2018 for Linux 4.14.10-1-ARCH x86_64

Compiled in features:

System config file: /etc/conky/conky.conf
Package library path: /usr/lib/conky

 General:
  * math
  * hddtemp
  * portmon
  * IPv6
  * Curl
  * RSS
  * Weather (METAR)
  * Weather (XOAP)
  * wireless
  * support for IBM/Lenovo notebooks
  * nvidia
  * builtin default configuration
  * old configuration syntax
  * Imlib2
  * apcupsd
  * iostats
  * ncurses
  * Internationalization support

 Lua bindings:
  * Cairo
  * Imlib2
  * RSVG
 X11:
  * Xdamage extension
  * Xinerama extension (virtual display)
  * XDBE (double buffer extension)
  * Xft
  * ARGB visual
  * Own window

 Music detection:
  * MPD
  * MOC

 Default values:
  * Netdevice: eth0
  * Local configfile: $HOME/.conkyrc
  * Localedir: /usr/share/locale
  * Maximum netdevices: 64
  * Maximum text size: 16384
  * Size text buffer: 256

My conky.conf:

-- vim: ts=4 sw=4 noet ai cindent syntax=lua
--[[
Conky, a system monitor, based on torsmo

Any original torsmo code is licensed under the BSD license

All code written since the fork of torsmo is licensed under the GPL

Please see COPYING for details

Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
Copyright (c) 2005-2012 Brenden Matthews, Philip Kovacs, et. al. (see AUTHORS)
All rights reserved.

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
]]

conky.config = {
    alignment = 'top_left',
    background = false,
    border_width = 1,
    cpu_avg_samples = 2,
    default_color = '#392f3d',
    default_outline_color = 'grey',
    default_shade_color = 'grey',
    double_buffer = true,
    draw_borders = false,
    draw_graph_borders = true,
    draw_outline = false,
    draw_shades = false,
    use_xft = true,
    font = 'Ubuntu:size=12',
    gap_x = 55,
    gap_y = 55,
    minimum_height = 5,
    minimum_width = 5,
    net_avg_samples = 2,
    no_buffers = true,
    out_to_console = false,
    out_to_stderr = false,
    extra_newline = false,
    own_window = true,
    own_window_class = 'Conky',
    own_window_type = 'desktop',
    own_window_argb_visual = true,
    own_window_argb_value = 0,
    own_window_hints = "sticky",
    stippled_borders = 0,
    update_interval = 1.0,
    uppercase = false,
    use_spacer = 'none',
    show_graph_scale = false,
    show_graph_range = false,
    xinerama_head = tonumber(os.getenv("conkydisplay")),
    pad_percents = 3,
    lua_load = '~/.config/conky/test.lua',
    lua_draw_hook_pre = "test"
}

conky.text = [[
${font Ubuntu:size=34}${time %H:%M}${font Ubuntu:size=18}
${font Ubuntu:size=20}${time %A, %e %B}
]]

and test.lua

require("cairo")

function conky_test()
font="Mono"
font_size=12
text="hello world"
xpos,ypos=100,100
red,green,blue,alpha=1,1,1,1
font_slant=CAIRO_FONT_SLANT_NORMAL
font_face=CAIRO_FONT_WEIGHT_NORMAL
----------------------------------
cairo_select_font_face (cr, font, font_slant, font_face);
cairo_set_font_size (cr, font_size)
cairo_set_source_rgba (cr,red,green,blue,alpha)
cairo_move_to (cr,xpos,ypos)
cairo_show_text (cr,text)
cairo_stroke (cr)
end
dbriba commented 6 years ago

I test your conky and test.lua and I have this error: conky: desktop window (260000a) is subwindow of root window (284) conky: window type - desktop conky: drawing to created window (0x5800002) conky: drawing to double buffer Segmentation fault (core dumped)

I solve that by replacing lua_load = '~/.config/conky/test.lua',

with the entire path of test.lua, in my case test.lua is in my repertory and is: lua_load = '/home/dominique/test.lua',

The conky lauch, but there is another error: conky: llua_do_call: function conky_test execution failed: attempt to call a nil value

But I don't know how solve that.

Targuinia commented 6 years ago

Full path crashes nonetheless. conky: llua_do_call: function conky_test execution failed: attempt to call a nil value is what you get when the function doesn't exist, AFAIK.

dbriba commented 6 years ago

Just one question: why use lua to display words ? It's more easy use directly conky.

Targuinia commented 6 years ago

This is just a script I quickly took from the wiki for testing purposes

dbriba commented 6 years ago

Can you take me the address where you take this script ?

Targuinia commented 6 years ago

https://github.com/brndnmtthws/conky/wiki/Using-Lua-scripts-in-conky:-Displaying-stuff-in-conky

Targuinia commented 6 years ago

Closing on behalf of I am an idiot and I didn't properly read the rest of the wiki, I hadn't included the things from the first page.