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

1.10.0 Randomly fails with memory allocation error after some time #103

Closed corpix closed 8 years ago

corpix commented 9 years ago

I am using Archlinux.

Log:

...
Jul 02 05:58:47 machine conky[14691]: conky: desktop window (268) is root window
Jul 02 05:58:47 machine conky[14691]: conky: window type - desktop
Jul 02 05:58:47 machine conky[14691]: conky: drawing to created window (0x2400001)
Jul 02 05:58:47 machine conky[14691]: conky: drawing to double buffer
Jul 02 06:02:46 machine conky[14691]: conky: std::bad_alloc

Waiting for next fail to collect more data.

Lompik commented 9 years ago

I was having the same std::bad_alloc error but using conky to print to console.

I removed all reference to MPD (music player daemon) in the config file and the random errors are more rare. .

cpmdolyp commented 9 years ago

I was having the same std::bad_alloc

the other information is normal conky: desktop window (297) is root window conky: window type - override conky: drawing to created window (0x1600001) conky: drawing to double buffer conky: forked to background, pid is 24319

aereaux commented 9 years ago

I'm also having what appears to be the same problem. Launching conky -DD gives me:

DEBUG(0) [/build/conky/src/conky-1.10.0/src/conky.cc:2671]: reading contents from config file '/home/user/.conkyrc'
conky: desktop window (1c00027) is subwindow of root window (d4)
DEBUG(0) [/build/conky/src/conky-1.10.0/src/x11.cc:587]: Found ARGB Visual
conky: window type - desktop
conky: drawing to created window (0xa00002)
conky: drawing to double buffer
DEBUG(1) [/build/conky/src/conky-1.10.0/src/core.cc:1913]: no templates to replace
DEBUG(1) [/build/conky/src/conky-1.10.0/src/core.cc:576]: Adding $cpu for CPU 0
DEBUG(1) [/build/conky/src/conky-1.10.0/src/core.cc:594]: Adding $cpugraph for CPU 0
DEBUG(1) [/build/conky/src/conky-1.10.0/src/core.cc:1913]: no templates to replace
DEBUG(1) [/build/conky/src/conky-1.10.0/src/core.cc:1913]: no templates to replace
DEBUG(1) [/build/conky/src/conky-1.10.0/src/core.cc:1913]: no templates to replace
DEBUG(0) [/build/conky/src/conky-1.10.0/src/specials.cc:460]: reallocing graph from 0 to 210
DEBUG(0) [/build/conky/src/conky-1.10.0/src/specials.cc:460]: reallocing graph from 0 to 210
DEBUG(1) [/build/conky/src/conky-1.10.0/src/conky.cc:846]: jumping
DEBUG(0) [/build/conky/src/conky-1.10.0/src/specials.cc:460]: reallocing graph from 0 to 439
DEBUG(0) [/build/conky/src/conky-1.10.0/src/specials.cc:460]: reallocing graph from 0 to 439
DEBUG(0) [/build/conky/src/conky-1.10.0/src/specials.cc:460]: reallocing graph from 0 to 439
DEBUG(1) [/build/conky/src/conky-1.10.0/src/conky.cc:846]: jumping

and then a short while later:

conky: std::bad_alloc

Sometimes, however, I get different errors as well. I'll see if I can catch one later.

Edit: I was able to catch one of the other errors I was getting in gdb (no debug symbols, though):

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff5638b68 in __memcpy_avx_unaligned () from /usr/lib/libc.so.6
(gdb) bt f
#0  0x00007ffff5638b68 in __memcpy_avx_unaligned () from /usr/lib/libc.so.6
No symbol table info available.
#1  0x00007ffff5b9a070 in copy (__n=<optimized out>, __s2=<optimized out>, 
    __s1=<optimized out>)
    at /build/gcc/src/gcc-build/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits/char_traits.h:275
No locals.
#2  _M_copy (__n=<optimized out>, __s=<optimized out>, __d=<optimized out>)
    at /build/gcc/src/gcc-build/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.h:2757
No locals.
#3  std::string::_Rep::_M_clone (this=0x7fffb800e3f0, __alloc=..., 
    __res=__res@entry=0)
    at /build/gcc/src/gcc-build/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.tcc:1075
        __requested_cap = <optimized out>
        __r = 0x79c830
#4  0x00007ffff5b9a77c in _M_grab (__alloc2=..., __alloc1=..., 
    this=<optimized out>)
    at /build/gcc/src/gcc-build/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.h:2625
No locals.
#5  std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string (this=0x7fffffffd6e8, __str=...)
    at /build/gcc/src/gcc-build/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.tcc:617
No locals.
#6  0x0000000000476df5 in ?? ()
No symbol table info available.
#7  0x000000000047a219 in print_mpd_album(text_object*, char*, int) ()
No symbol table info available.
#8  0x0000000000436b53 in generate_text_internal(char*, int, text_object) ()
No symbol table info available.
#9  0x00000000004540ee in print_scroll(text_object*, char*, int) ()
No symbol table info available.
#10 0x0000000000436b53 in generate_text_internal(char*, int, text_object) ()
No symbol table info available.
#11 0x0000000000436def in ?? ()
No symbol table info available.
#12 0x0000000000437ca9 in ?? ()
No symbol table info available.
#13 0x0000000000428bc1 in main ()
No symbol table info available.

Edit (2): And another (slightly different) one:

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff5638b68 in __memcpy_avx_unaligned () from /usr/lib/libc.so.6
(gdb) bt f
#0  0x00007ffff5638b68 in __memcpy_avx_unaligned () from /usr/lib/libc.so.6
No symbol table info available.
#1  0x00007ffff5b9a070 in copy (__n=<optimized out>, __s2=<optimized out>, 
    __s1=<optimized out>)
    at /build/gcc/src/gcc-build/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits/char_traits.h:275
No locals.
#2  _M_copy (__n=<optimized out>, __s=<optimized out>, __d=<optimized out>)
    at /build/gcc/src/gcc-build/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.h:2757
No locals.
#3  std::string::_Rep::_M_clone (this=0x7fffb800e8c0, __alloc=..., 
    __res=__res@entry=0)
    at /build/gcc/src/gcc-build/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.tcc:1075
        __requested_cap = <optimized out>
        __r = 0x79c1d0
#4  0x00007ffff5b9a77c in _M_grab (__alloc2=..., __alloc1=..., 
    this=<optimized out>)
    at /build/gcc/src/gcc-build/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.h:2625
No locals.
#5  std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string (this=0x7fffffffd7c0, __str=...)
    at /build/gcc/src/gcc-build/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.tcc:617
No locals.
#6  0x0000000000476d85 in ?? ()
No symbol table info available.
#7  0x0000000000477877 in print_mpd_length(text_object*, char*, int) ()
No symbol table info available.
#8  0x0000000000436b53 in generate_text_internal(char*, int, text_object) ()
No symbol table info available.
#9  0x0000000000436def in ?? ()
No symbol table info available.
#10 0x0000000000437ca9 in ?? ()
No symbol table info available.
#11 0x0000000000428bc1 in main ()
No symbol table info available.
Lompik commented 8 years ago

For what is worth, compiling conky with debug flag ( -DCMAKE_BUILD_TYPE= Debug) fixed (or rather drastically diminished) the segmentation fault issues on my machine.

mtcs commented 8 years ago

I am heaving the same issue when I add MPD in to the config file. Ps.: It is most likely that adding " -DCMAKE_BUILD_TYPE= Debug" don't really solve the problem, it just hides the segmentation fault. It is common to printf hide segfauts...

bldewolf commented 8 years ago

I have been getting the "conky: std::bad_alloc" error so I started running conky in gdb to catch this. I finally got a backtrace, but it doesn't look good. Here's the whole thing (I set a breakpoint on write, so there's ~8 extra useless frames):

#0  0x00007ffff5c221a0 in write () from /usr/lib/libc.so.6
#1  0x00007ffff5bb96ff in _IO_new_file_write () from /usr/lib/libc.so.6
#2  0x00007ffff5bb8d03 in new_do_write () from /usr/lib/libc.so.6
#3  0x00007ffff5bb9cf6 in __GI__IO_file_xsputn () from /usr/lib/libc.so.6
#4  0x00007ffff5baf9eb in fwrite () from /usr/lib/libc.so.6
#5  0x00007ffff618fa56 in __gnu_cxx::__verbose_terminate_handler ()
    at /build/gcc-multilib/src/gcc-5.2.0/libstdc++-v3/libsupc++/vterminate.cc:67
#6  0x00007ffff618d996 in __cxxabiv1::__terminate (handler=<optimized out>)
    at /build/gcc-multilib/src/gcc-5.2.0/libstdc++-v3/libsupc++/eh_terminate.cc:47
#7  0x00007ffff618d9e1 in std::terminate ()
    at /build/gcc-multilib/src/gcc-5.2.0/libstdc++-v3/libsupc++/eh_terminate.cc:57
#8  0x00007ffff618dbf8 in __cxxabiv1::__cxa_throw (obj=0x7fffc8000940, 
    tinfo=0x6a2790 <typeinfo for std::bad_alloc@@GLIBCXX_3.4>, 
    dest=0x422530 <std::bad_alloc::~bad_alloc()@plt>)
    at /build/gcc-multilib/src/gcc-5.2.0/libstdc++-v3/libsupc++/eh_throw.cc:87
#9  0x00007ffff618e18c in operator new (sz=140736683106272)
    at /build/gcc-multilib/src/gcc-5.2.0/libstdc++-v3/libsupc++/new_op.cc:54
#10 0x00007ffff61cf269 in __gnu_cxx::new_allocator<char>::allocate (
    this=<optimized out>, __n=<optimized out>)
    at /build/gcc-multilib/src/gcc-build/x86_64-unknown-linux-gnu/libstdc++-v3/include/ext/new_allocator.h:104
#11 std::string::_Rep::_S_create (__capacity=140736683106247, 
    __old_capacity=<optimized out>, __alloc=...)
    at /build/gcc-multilib/src/gcc-build/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.tcc:1051
#12 0x00007ffff61d004b in std::string::_Rep::_M_clone (this=0x7fffd000d500, 
    __alloc=..., __res=__res@entry=0)
    at /build/gcc-multilib/src/gcc-build/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.tcc:1073
#13 0x00007ffff61d077c in std::string::_Rep::_M_grab (__alloc2=..., 
    __alloc1=..., this=<optimized out>)
    at /build/gcc-multilib/src/gcc-build/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.h:2625
#14 std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string (this=0x7fffffffdaa0, __str=...)
    at /build/gcc-multilib/src/gcc-build/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.tcc:617
#15 0x00000000004653da in (anonymous namespace)::mpd_result::mpd_result (
    this=0x7fffffffda50) at /home/bldewolf/bulk/conky/src/mpd.cc:122
#16 conky::callback<(anonymous namespace)::mpd_result>::get_result_copy (
    this=0x7432d0) at /home/bldewolf/bulk/conky/src/update-cb.hh:246
#17 (anonymous namespace)::get_mpd ()
    at /home/bldewolf/bulk/conky/src/mpd.cc:309
#18 0x000000000046a1b9 in print_mpd_file (obj=<optimized out>, p=0x713ed5 "", 
    p_max_size=16315) at /home/bldewolf/bulk/conky/src/mpd.cc:409
#19 0x000000000042db13 in generate_text_internal (p=0x713ed5 "", 
    p@entry=0x713e90 "Status:   Paused\nTitle:    My Friend Fats\nArtist:   Primus\nFilename: ", p_max_size=16315, root=...)
    at /home/bldewolf/bulk/conky/src/conky.cc:858
#20 0x000000000043012a in generate_text ()
    at /home/bldewolf/bulk/conky/src/conky.cc:927
#21 update_text () at /home/bldewolf/bulk/conky/src/conky.cc:2025
#22 0x00000000004328f9 in main_loop ()
    at /home/bldewolf/bulk/conky/src/conky.cc:2107
#23 0x00000000004256a5 in main (argc=1, argv=0x7fffffffe1a8)
    at /home/bldewolf/bulk/conky/src/conky.cc:3154

Frame 11's arguments tell us one of the strings in the struct it's copying is unreasonably large. If we poke around in frame 15:

(gdb) frame 15
#15 0x00000000004653da in (anonymous namespace)::mpd_result::mpd_result (
    this=0x7fffffffda50) at /home/bldewolf/bulk/conky/src/mpd.cc:122
122     struct mpd_result {
(gdb) print this->file
$44 = ""
(gdb) print this->file.length()
$45 = 140736683103584
(gdb) print this->file.capacity()
$46 = 78

It looks like the string's length has been corrupted. The string's content is still available via this->file.c_str(), but that doesn't really help us. I'm not really sure where to go from here.

ghost commented 6 years ago

I've just tried the latest Conky on Mint 19 and on first run I get conky: basic_string::_M_create and on subsequent runs std::bad_alloc. I think the errors may be lua related.

EDIT: The version of conky in Mint 19 repositories seems to have the problem too, though perhaps I did not uninstall the git version correctly.

brndnmtthws commented 6 years ago

@CottonEaster annoyingly CMake doesn't actually generate an uninstall target, so you might want to try going through the whole process again.

ghost commented 6 years ago

@brndnmtthws: thanks, but I do not understand. Are you suggesting that I restore the old, working version of conky by compiling from an older version of the source code? Anyway, I have restored an older version of conky already - by means of a system-wide restore.

brndnmtthws commented 6 years ago

@CottonEaster I'm not sure how you uninstalled it, but I only meant that you can't do a make uninstall with CMake to remove Conky after you've done a make install.

As for your particular issue, I'm not sure what's causing that, but a lot has changed in master, so if you can capture a stacktrace with gdb that would be helpful.

ghost commented 6 years ago

I fear I do not want to risk having to do another restore. Sorry.

ghost commented 6 years ago

Having reacquainted myself with this thread, I've braved a reinstallation of the github version of Conky.

Results of trying to run that version are as follows.

$ conky -DD
DEBUG(0) [/home/nicholas/Downloads/Conky/git/conky/src/logging.h:112]: reading contents from config file '/home/nicholas/conky/.conkyrc'
DEBUG(0) [/home/nicholas/Downloads/Conky/git/conky/src/logging.h:112]: Fixed xinerama area to: 0 0 2560 1440
DEBUG(0) [/home/nicholas/Downloads/Conky/git/conky/src/logging.h:112]: Fixed xinerama area to: 0 0 2560 1440
conky: desktop window (3a01450) is subwindow of root window (1a0)
DEBUG(0) [/home/nicholas/Downloads/Conky/git/conky/src/logging.h:112]: Found ARGB Visual
conky: window type - desktop
conky: drawing to created window (0x7a00002)
conky: drawing to double buffer
DEBUG(1) [/home/nicholas/Downloads/Conky/git/conky/src/logging.h:112]: no templates to replace
DEBUG(1) [/home/nicholas/Downloads/Conky/git/conky/src/logging.h:112]: no templates to replace
DEBUG(1) [/home/nicholas/Downloads/Conky/git/conky/src/logging.h:112]: no templates to replace
DEBUG(1) [/home/nicholas/Downloads/Conky/git/conky/src/logging.h:112]: no templates to replace
DEBUG(1) [/home/nicholas/Downloads/Conky/git/conky/src/logging.h:112]: no templates to replace
DEBUG(1) [/home/nicholas/Downloads/Conky/git/conky/src/logging.h:112]: no templates to replace
DEBUG(1) [/home/nicholas/Downloads/Conky/git/conky/src/logging.h:112]: no templates to replace
DEBUG(1) [/home/nicholas/Downloads/Conky/git/conky/src/logging.h:112]: no templates to replace
DEBUG(1) [/home/nicholas/Downloads/Conky/git/conky/src/logging.h:112]: no templates to replace
DEBUG(1) [/home/nicholas/Downloads/Conky/git/conky/src/logging.h:112]: no templates to replace
DEBUG(1) [/home/nicholas/Downloads/Conky/git/conky/src/logging.h:112]: no templates to replace
DEBUG(1) [/home/nicholas/Downloads/Conky/git/conky/src/logging.h:112]: no templates to replace
DEBUG(1) [/home/nicholas/Downloads/Conky/git/conky/src/logging.h:112]: no templates to replace
DEBUG(1) [/home/nicholas/Downloads/Conky/git/conky/src/logging.h:112]: Adding $cpu for CPU 0
DEBUG(1) [/home/nicholas/Downloads/Conky/git/conky/src/logging.h:112]: no templates to replace
DEBUG(1) [/home/nicholas/Downloads/Conky/git/conky/src/logging.h:112]: Adding $cpu for CPU 0
DEBUG(1) [/home/nicholas/Downloads/Conky/git/conky/src/logging.h:112]: Adding $cpu for CPU 0
DEBUG(1) [/home/nicholas/Downloads/Conky/git/conky/src/logging.h:112]: no templates to replace
DEBUG(1) [/home/nicholas/Downloads/Conky/git/conky/src/logging.h:112]: no templates to replace
DEBUG(1) [/home/nicholas/Downloads/Conky/git/conky/src/logging.h:112]: no templates to replace
DEBUG(1) [/home/nicholas/Downloads/Conky/git/conky/src/logging.h:112]: no templates to replace
DEBUG(1) [/home/nicholas/Downloads/Conky/git/conky/src/logging.h:112]: no templates to replace
DEBUG(0) [/home/nicholas/Downloads/Conky/git/conky/src/logging.h:112]: parsed hwmon args: '1' 'temp' 3 1.000000 0.000000

DEBUG(1) [/home/nicholas/Downloads/Conky/git/conky/src/logging.h:112]: no templates to replace
DEBUG(0) [/home/nicholas/Downloads/Conky/git/conky/src/logging.h:112]: parsed hwmon args: '1' 'temp' 3 1.000000 0.000000

DEBUG(1) [/home/nicholas/Downloads/Conky/git/conky/src/logging.h:112]: no templates to replace
DEBUG(0) [/home/nicholas/Downloads/Conky/git/conky/src/logging.h:112]: parsed hwmon args: '1' 'temp' 3 1.000000 0.000000

DEBUG(0) [/home/nicholas/Downloads/Conky/git/conky/src/logging.h:112]: parsed hwmon args: '1' 'temp' 1 1.000000 0.000000

DEBUG(1) [/home/nicholas/Downloads/Conky/git/conky/src/logging.h:112]: no templates to replace
DEBUG(1) [/home/nicholas/Downloads/Conky/git/conky/src/logging.h:112]: no templates to replace
DEBUG(1) [/home/nicholas/Downloads/Conky/git/conky/src/logging.h:112]: no templates to replace
DEBUG(1) [/home/nicholas/Downloads/Conky/git/conky/src/logging.h:112]: no templates to replace
DEBUG(1) [/home/nicholas/Downloads/Conky/git/conky/src/logging.h:112]: no templates to replace
DEBUG(1) [/home/nicholas/Downloads/Conky/git/conky/src/logging.h:112]: Adding $cpu for CPU 0
conky: std::bad_alloc

I found that commenting-out my lua scripts, within my conkyrc, did not prevent the 'bad_alloc' error.

But I found that commenting out this line, in the 'config' section of the conkyrc file, did forestall the problem:

update_interval_on_battery = 1.25,