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

segmentation fault when calling pid_nice #206

Closed
mferretti opened this issue Feb 4, 2016 · 9 comments
Closed

segmentation fault when calling pid_nice #206

mferretti opened this issue Feb 4, 2016 · 9 comments

Comments

@mferretti
Copy link

Hi,

I am moving from my old conky to the new one (on a test machine) installed with debian testing. I have managed to make everything I need work except for getting the nice of a pid.

In the old version (1.9.0) I used this line ${pid_nice ${top pid 1}} but as soon as I put that in version 1.10 conky crashes with segmentation fault

I have tried to download the master and compile it (with defaults) but it still crashes (segmentation fault)

I have tried to run conky with the -D option but I get nothing better than this:
~/software/bin$ ./conky -D -c ../../.conkyrc DEBUG(0) [/build/conky-A6_O5I/conky-1.10.1/src/conky.cc:2685]: reading contents from config file '/home/marco/.conkyrc' conky: desktop window (1e00003) is subwindow of root window (7e) conky: window type - desktop conky: drawing to created window (0xe00001) conky: drawing to double buffer DEBUG(0) [/build/conky-A6_O5I/conky-1.10.1/src/specials.cc:507]: reallocing graph from 0 to 75 DEBUG(0) [/build/conky-A6_O5I/conky-1.10.1/src/specials.cc:507]: reallocing graph from 0 to 75 Segmentation fault
Here's the the config that crashes it
`-- 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_right',
background = false,
border_width = 1,
cpu_avg_samples = 2,
default_color = 'E0DFDE',
color0 = 'DD3A21',
default_outline_color = 'white',
default_shade_color = 'white',
draw_borders = false,
draw_graph_borders = true,
draw_outline = false,
draw_shades = false,
use_xft = true,
font = 'monofour:size=6',
minimum_height = 249,
minimum_width = 850,
maximum_width = 280,
gap_x = 1,
gap_y = 25,
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_transparent = true,
stippled_borders = 0,
update_interval = 1.0,
uppercase = false,
use_spacer = 'none',
show_graph_scale = false,
show_graph_range = false,
update_interval = 1,
total_run_times = 0,
double_buffer = true,
no_buffers = true,
net_avg_samples = 2,
text_buffer_size = 1024
}

conky.text = [[
${GOTO 36}Kernel:${GOTO 120}${kernel}
${GOTO 36}RAM:${GOTO 120}${membar 10,75} ${memperc} %
${GOTO 36}SWAP:${GOTO 120}${swapbar 10,75} ${swapperc} %
${GOTO 36}$stippled_hr
${GOTO 36}${font monofur:bold:size=8}${color0}Cpu Detail :${font}${color}
${GOTO 36}Current load : ${cpu cpu1}%
${GOTO 36}Temperature : ${execi 4 sensors | grep -A 0 'Core 0' | cut -c16-21}
${GOTO 36}${cpubar cpu1 10,240}
${GOTO 36}$stippled_hr
${GOTO 36}${font monofur:bold:size=8}${color0}Disks Usage${font}${color}
${GOTO 36}System (/):${GOTO 120}${fs_used /} (${fs_free_perc}% free)
${GOTO 36}${GOTO 36}${fs_bar 10,240 /}
${GOTO 36}Temperature : ${execi 30 /usr/sbin/hddtemp /dev/sda | cut -c24-28} ${GOTO 120}
${GOTO 36}$stippled_hr
${GOTO 36}${font monofur:bold:size=8}${color0}Network${font}${color}
${GOTO 36}Upspeed:${GOTO 120}${upspeedgraph wlan0 10,75 B7B2AD B7B2AD}
${GOTO 36}Downspeed:${GOTO 120}${downspeedgraph wlan0 10,75 B7B2AD B7B2AD}
${GOTO 36}Uploaded:${GOTO 120}${totalup wlan0}
${GOTO 36}Downloaded:${GOTO 120}${totaldown wlan0}
${GOTO 36}Local IP:${GOTO 120}${addr wlan0}
${GOTO 36}$stippled_hr
${GOTO 36}${font monofur:bold:size=8}${color0}Processes: ${font}${color}$processes ${font monofur:bold:size=8}${color0}Run: ${font}${color}$running_processes ${font monofur:bold:size=8}${color0}Threads: ${font}${color}$running_threads
${GOTO 36}$stippled_hr
${GOTO 36}${font monofur:bold:size=8}${color0}Top 5 Processes${font}${color}
${GOTO 36}${font monofur:bold:size=8}NAME $alignr PID NICE CPU${font}
${GOTO 36}${top name 1} $alignr ${top pid 1} ${pid_nice ${top pid 1}} ${top cpu 1} %
${GOTO 36}${top name 2} $alignr ${top pid 2} -1 ${top cpu 2} %
${GOTO 36}${top name 3} $alignr ${top pid 3} -1 ${top cpu 3} %
${GOTO 36}${top name 4} $alignr ${top pid 4} -1 ${top cpu 4} %
${GOTO 36}$stippled_hr
${GOTO 36}Uptime:${GOTO 120}${uptime}
${GOTO 36}$stippled_hr
${GOTO 36}Current Desktop:${GOTO 140}${desktop_name} (${desktop} of ${desktop_number})
${GOTO 40}${font monofur:bold:size=8}${execi 300 date +"%d %B %Y"} ${time %I:%M}${font}
${GOTO 36}$stippled_hr
]]
`
Let me know if I can do something more

@chepioq
Copy link

chepioq commented Feb 5, 2016

I confirm core dump with this line : ${pid_nice ${top pid 1}}
For test I replace ${top pid 1} by the number of a know pid, like ${pid_nice 787} for same issue, core dump.

@mferretti
Copy link
Author

Hi,
just to say that I am still seeing this on conky 1.10.1

@su8
Copy link
Collaborator

su8 commented Aug 3, 2018

@lasers I'm not getting a segfault/coredump, if you get can you gdb() it ?

@lasers
Copy link
Contributor

lasers commented Aug 3, 2018

Segfault just with

conky.config = {}
conky.text = [[${pid_nice ${top pid 1}}]]
(gdb) r -c /tmp/conky.txt
Starting program: /usr/local/bin/conky -c /tmp/conky.txt
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
conky: desktop window (25a) is root window
conky: drawing to desktop window
conky: can't load font '6x10'
conky: can't load font '6x10'
[New Thread 0x7fffee3f5700 (LWP 1965)]

Thread 1 "conky" received signal SIGSEGV, Segmentation fault.
print_pid_nice(text_object*, char*, int) () at /home/chris/src/conky/src/proc.cc:243
243       if (*(obj->data.s) != 0) {
(gdb) bt full
#0  print_pid_nice(text_object*, char*, int) () at /home/chris/src/conky/src/proc.cc:243
        buf = 0x0
        bytes_read = 0
        nice_value = -5389795094225177600
        pathbuf = "\000\000\000\000\000\000\000\000\000\264\220\f\353\231\063\265\000\000\000\000\000\000\000\000\353\242W\366\377\177", '\000' <repeats 11 times>, "\264\220\f\353\231\063\265\001\000\000\000\000\000\000\000\353\242W\366\377\177\000"
        objbuf = std::unique_ptr<char []> = {get() = 0x55555588e060 "32759"}
#1  0x0000555555574633 in generate_text_internal (p=p@entry=0x5555558716c0 "",
    p_max_size=16384, root=...) at /home/chris/src/conky/src/conky.cc:860
        obj = 0x555555870f90
        a = <optimized out>
#2  0x00005555555772fd in generate_text ()
    at /usr/include/c++/8.1.1/bits/unique_ptr.h:342
        i = <optimized out>
        k = <optimized out>
        mw = <optimized out>
        tbs = <optimized out>
        ui = <optimized out>
        p = 0x5555558716c0 ""
        j = <optimized out>
        time = <optimized out>
        p = <optimized out>
        i = <optimized out>
        j = <optimized out>
        k = <optimized out>
        mw = <optimized out>
        tbs = <optimized out>
        ui = <optimized out>
        time = <optimized out>
        tmp_p = <optimized out>
#3  update_text () at /home/chris/src/conky/src/conky.cc:1980
No locals.
#4  0x000055555557a46e in main_loop () at /home/chris/src/conky/src/conky.cc:2094
        fdsr = {fds_bits = {0 <repeats 16 times>}}
        tv = {tv_sec = 0, tv_usec = 0}
        s = <optimized out>
        terminate = 0
        t = <optimized out>
        inotify_config_wd = 1
        inotify_buff = '\000' <repeats 208 times>...
#5  0x000055555556a6fe in main () at /home/chris/src/conky/src/conky.cc:3162
        curl_global = <optimized out>
#6  0x00007ffff4e3e06b in __libc_start_main () from /usr/lib/libc.so.6
No symbol table info available.
#7  0x000055555556f36a in _start () at /home/chris/src/conky/src/conky.cc:3212
No symbol table info available.
(gdb) Quit
(gdb)

@su8
Copy link
Collaborator

su8 commented Aug 3, 2018

If we change https://github.com/brndnmtthws/conky/blob/master/src/proc.cc#L243

to

diff --git a/src/proc.cc b/src/proc.cc
index eaafd51b..9aeee492 100644
--- a/src/proc.cc
+++ b/src/proc.cc
@@ -240,7 +240,7 @@ void print_pid_nice(struct text_object *obj, char *p, int p_max_size) {
 
   generate_text_internal(objbuf.get(), max_user_text.get(*state), *obj->sub);
 
-  if (*(obj->data.s) != 0) {
+  if (obj->data.s) {
     snprintf(pathbuf, 64, PROCDIR "/%d/stat", strtopid(objbuf.get()));
     buf = readfile(pathbuf, &bytes_read, 1);
     if (buf != nullptr) {

we no more get segfault/coredumps, but whatever pid number is passed the whole "if" section goes to "else" where it's printed $pid_nice didn't receive a argument.

edit: the solution was to add ! in front of obj->data.s.

@lasers
Copy link
Contributor

lasers commented Aug 3, 2018

I got the same thing from this diff. conky: $pid_nice didn't receive a argument.

When I tried conky.text = [[${top pid 1}]] instead, I get segfault in terminal, but few [New Thread 0x7fffee01d700 (LWP 26553)] in the gdb. Anyhow, I think I got this different one, but ur diff probably fixed it...

Thread 1 "conky" received signal SIGSEGV, Segmentation fault.
print_pid_nice(text_object*, char*, int) ()
    at /home/chris/src/conky/src/proc.cc:243
243       if (*(obj->data.s) != 0) {                                        
(gdb) r -c /tmp/conky.conf Quit  

Not sure what you want to do here. Give it to Brenden? EDIT: OH okay, Ill test it now.

@lasers
Copy link
Contributor

lasers commented Aug 3, 2018

Your fix does not work for me. I think I get a thread running or something, but no output in the terminal. Frozen like this...

2d [chris:~/src/conky/build] master(+1/-1) ± conky -c /tmp/conky.conf                      
conky: desktop window (25a) is root window
conky: drawing to desktop window
conky: can't load font '6x10'
conky: can't load font '6x10'

EDIT: Wait... This got printed in X11 instead of console.

@lasers
Copy link
Contributor

lasers commented Aug 3, 2018

@su8 The fix is good. ❤️

0                                                                                                             
1                                                                                                             
1                                                                                                             
1                                                                                                             
2                                                                                                             
1                                                                                                             
2                                                                                                             
1                                                                                                             
2                                                                                                             
2                                                                                                             
0                                                                                                             
0                                                                                                             
0                                                                                                             
2                                                                                                             
1                                                                                                             
0                                                                                                             
2                                                                                                             
0                                                                                                             
5                                                                                                             
9                                                                                                             
0                                                                                                             
9                                                                                                             
14

brndnmtthws added a commit that referenced this issue Aug 4, 2018
…nd mouse speed in percentage and generate random password of chosen length and get the cpu clock speed from assembly (#550)

* Add new text object to capitalize the first character of each word

* Fix for issue #46

* Fix for issue #35

* Fix for issue #35

* Fix for #206

* Fix for #474

* Add new "temp2" variable to print the temperature in floating number

* Make the "temp2" variable static and add some explanation above it

* openbsd.cc: Add one more formal parameter to "temp_print()"

* extras/convert.lua: change url to wiki page (#554)
@su8
Copy link
Collaborator

su8 commented Aug 4, 2018

Thank you for reporting, it has been fixed in a3b7905 commit

@su8 su8 closed this as completed Aug 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants