allinurl / goaccess

GoAccess is a real-time web log analyzer and interactive viewer that runs in a terminal in *nix systems or through your browser.
https://goaccess.io
MIT License
18.12k stars 1.1k forks source link

Updating to the new hash table code panics GoAccess #2101

Closed dertuxmalwieder closed 3 years ago

dertuxmalwieder commented 3 years ago

After updating 3bce68e96b436eae5592d2b7f2234baab707e30a to 319b65a and installing the new version (make clean ; make && make install) over the previous one, calling the binary panics, probably when storing the hash tables (because the output file is generated just well first):

*** Error in `/home/REDACTED/bin/goaccess': corrupted size vs. prev_size: 0x0000000001b14cd0 ***
======= Backtrace: =========
/lib64/libc.so.6(+0x80c37)[0x7f06ad215c37]
/lib64/libc.so.6(+0x8120e)[0x7f06ad21620e]
/home/REDACTED/bin/goaccess[0x413ba2]
/home/REDACTED/bin/goaccess(free_storage+0x178)[0x421068]
/home/REDACTED/bin/goaccess[0x42243c]
/home/REDACTED/bin/goaccess(main+0x2b1)[0x40a091]
/lib64/libc.so.6(__libc_start_main+0xf5)[0x7f06ad1b7555]
/home/REDACTED/bin/goaccess[0x40bac2]
======= Memory map: ========
00400000-00409000 r--p 00000000 08:02 1619183933                         /home/REDACTED/bin/goaccess
00409000-00443000 r-xp 00009000 08:02 1619183933                         /home/REDACTED/bin/goaccess
00443000-004aa000 r--p 00043000 08:02 1619183933                         /home/REDACTED/bin/goaccess
004ab000-004ac000 r--p 000aa000 08:02 1619183933                         /home/REDACTED/bin/goaccess
004ac000-004b5000 rw-p 000ab000 08:02 1619183933                         /home/REDACTED/bin/goaccess
01afc000-05374000 rw-p 00000000 00:00 0                                  [heap]
7f06a0000000-7f06a0021000 rw-p 00000000 00:00 0 
7f06a0021000-7f06a4000000 ---p 00000000 00:00 0 
7f06a49fe000-7f06a4a13000 r-xp 00000000 08:02 1613193327                 /usr/lib64/libgcc_s-4.8.5-20150702.so.1
7f06a4a13000-7f06a4c12000 ---p 00015000 08:02 1613193327                 /usr/lib64/libgcc_s-4.8.5-20150702.so.1
7f06a4c12000-7f06a4c13000 r--p 00014000 08:02 1613193327                 /usr/lib64/libgcc_s-4.8.5-20150702.so.1
7f06a4c13000-7f06a4c14000 rw-p 00015000 08:02 1613193327                 /usr/lib64/libgcc_s-4.8.5-20150702.so.1
7f06a4c14000-7f06a4c15000 ---p 00000000 00:00 0 
7f06a4c15000-7f06a5415000 rw-p 00000000 00:00 0 
7f06a5415000-7f06ab957000 r--p 00000000 08:02 24981                      /usr/lib/locale/locale-archive
7f06ab957000-7f06ab9b7000 r-xp 00000000 08:02 1610672960                 /usr/lib64/libpcre.so.1.2.0
7f06ab9b7000-7f06abbb7000 ---p 00060000 08:02 1610672960                 /usr/lib64/libpcre.so.1.2.0
7f06abbb7000-7f06abbb8000 r--p 00060000 08:02 1610672960                 /usr/lib64/libpcre.so.1.2.0
7f06abbb8000-7f06abbb9000 rw-p 00061000 08:02 1610672960                 /usr/lib64/libpcre.so.1.2.0
7f06abbb9000-7f06abbdd000 r-xp 00000000 08:02 1629050671                 /usr/lib64/libselinux.so.1
7f06abbdd000-7f06abddc000 ---p 00024000 08:02 1629050671                 /usr/lib64/libselinux.so.1
7f06abddc000-7f06abddd000 r--p 00023000 08:02 1629050671                 /usr/lib64/libselinux.so.1
7f06abddd000-7f06abdde000 rw-p 00024000 08:02 1629050671                 /usr/lib64/libselinux.so.1
7f06abdde000-7f06abde0000 rw-p 00000000 00:00 0 
7f06abde0000-7f06abdf6000 r-xp 00000000 08:02 1611807867                 /usr/lib64/libresolv-2.17.so
7f06abdf6000-7f06abff6000 ---p 00016000 08:02 1611807867                 /usr/lib64/libresolv-2.17.so
7f06abff6000-7f06abff7000 r--p 00016000 08:02 1611807867                 /usr/lib64/libresolv-2.17.so
7f06abff7000-7f06abff8000 rw-p 00017000 08:02 1611807867                 /usr/lib64/libresolv-2.17.so
7f06abff8000-7f06abffa000 rw-p 00000000 00:00 0 
7f06abffa000-7f06abffd000 r-xp 00000000 08:02 1610673450                 /usr/lib64/libkeyutils.so.1.5
7f06abffd000-7f06ac1fc000 ---p 00003000 08:02 1610673450                 /usr/lib64/libkeyutils.so.1.5
7f06ac1fc000-7f06ac1fd000 r--p 00002000 08:02 1610673450                 /usr/lib64/libkeyutils.so.1.5
7f06ac1fd000-7f06ac1fe000 rw-p 00003000 08:02 1610673450                 /usr/lib64/libkeyutils.so.1.5
7f06ac1fe000-7f06ac20c000 r-xp 00000000 08:02 1627188530                 /usr/lib64/libkrb5support.so.0.1
7f06ac20c000-7f06ac40c000 ---p 0000e000 08:02 1627188530                 /usr/lib64/libkrb5support.so.0.1
7f06ac40c000-7f06ac40d000 r--p 0000e000 08:02 1627188530                 /usr/lib64/libkrb5support.so.0.1
7f06ac40d000-7f06ac40e000 rw-p 0000f000 08:02 1627188530                 /usr/lib64/libkrb5support.so.0.1
7f06ac40e000-7f06ac43f000 r-xp 00000000 08:02 1627188525                 /usr/lib64/libk5crypto.so.3.1
7f06ac43f000-7f06ac63e000 ---p 00031000 08:02 1627188525                 /usr/lib64/libk5crypto.so.3.1
7f06ac63e000-7f06ac640000 r--p 00030000 08:02 1627188525                 /usr/lib64/libk5crypto.so.3.1
7f06ac640000-7f06ac641000 rw-p 00032000 08:02 1627188525                 /usr/lib64/libk5crypto.so.3.1
7f06ac641000-7f06ac644000 r-xp 00000000 08:02 1610672807                 /usr/lib64/libcom_err.so.2.1
7f06ac644000-7f06ac843000 ---p 00003000 08:02 1610672807                 /usr/lib64/libcom_err.so.2.1
7f06ac843000-7f06ac844000 r--p 00002000 08:02 1610672807                 /usr/lib64/libcom_err.so.2.1
7f06ac844000-7f06ac845000 rw-p 00003000 08:02 1610672807                 /usr/lib64/libcom_err.so.2.1
7f06ac845000-7f06ac91e000 r-xp 00000000 08:02 1610967746                 /usr/lib64/libkrb5.so.3.3
7f06ac91e000-7f06acb1d000 ---p 000d9000 08:02 1610967746                 /usr/lib64/libkrb5.so.3.3
7f06acb1d000-7f06acb2b000 r--p 000d8000 08:02 1610967746                 /usr/lib64/libkrb5.so.3.3
7f06acb2b000-7f06acb2e000 rw-p 000e6000 08:02 1610967746                 /usr/lib64/libkrb5.so.3.3
7f06acb2e000-7f06acb78000 r-xp 00000000 08:02 1610673041                 /usr/lib64/libgssapi_krb5.so.2.2
7f06acb78000-7f06acd78000 ---p 0004a000 08:02 1610673041                 /usr/lib64/libgssapi_krb5.so.2.2
7f06acd78000-7f06acd79000 r--p 0004a000 08:02 1610673041                 /usr/lib64/libgssapi_krb5.so.2.2
7f06acd79000-7f06acd7b000 rw-p 0004b000 08:02 1610673041                 /usr/lib64/libgssapi_krb5.so.2.2
7f06acd7b000-7f06acd90000 r-xp 00000000 08:02 1610613132                 /usr/lib64/libz.so.1.2.7
7f06acd90000-7f06acf8f000 ---p 00015000 08:02 1610613132                 /usr/lib64/libz.so.1.2.7
7f06acf8f000-7f06acf90000 r--p 00014000 08:02 1610613132                 /usr/lib64/libz.so.1.2.7
7f06acf90000-7f06acf91000 rw-p 00015000 08:02 1610613132                 /usr/lib64/libz.so.1.2.7
7f06acf91000-7f06acf93000 r-xp 00000000 08:02 1611806505                 /usr/lib64/libdl-2.17.so
7f06acf93000-7f06ad193000 ---p 00002000 08:02 1611806505                 /usr/lib64/libdl-2.17.so
7f06ad193000-7f06ad194000 r--p 00002000 08:02 1611806505                 /usr/lib64/libdl-2.17.so
7f06ad194000-7f06ad195000 rw-p 00003000 08:02 1611806505                 /usr/lib64/libdl-2.17.so
7f06ad195000-7f06ad359000 r-xp 00000000 08:02 1611803925                 /usr/lib64/libc-2.17.so
7f06ad359000-7f06ad558000 ---p 001c4000 08:02 1611803925                 /usr/lib64/libc-2.17.so
7f06ad558000-7f06ad55c000 r--p 001c3000 08:02 1611803925                 /usr/lib64/libc-2.17.so
7f06ad55c000-7f06ad55e000 rw-p 001c7000 08:02 1611803925                 /usr/lib64/libc-2.17.so
7f06ad55e000-7f06ad563000 rw-p 00000000 00:00 0 
7f06ad563000-7f06ad57a000 r-xp 00000000 08:02 1611259803                 /usr/lib64/libpthread-2.17.so
7f06ad57a000-7f06ad779000 ---p 00017000 08:02 1611259803                 /usr/lib64/libpthread-2.17.so
7f06ad779000-7f06ad77a000 r--p 00016000 08:02 1611259803                 /usr/lib64/libpthread-2.17.so
7f06ad77a000-7f06ad77b000 rw-p 00017000 08:02 1611259803                 /usr/lib64/libpthread-2.17.so
7f06ad77b000-7f06ad77f000 rw-p 00000000 00:00 0 
7f06ad77f000-7f06ad7e6000 r-xp 00000000 08:02 1614493355                 /usr/lib64/libssl.so.1.0.2k
7f06ad7e6000-7f06ad9e6000 ---p 00067000 08:02 1614493355                 /usr/lib64/libssl.so.1.0.2k
7f06ad9e6000-7f06ad9ea000 r--p 00067000 08:02 1614493355                 /usr/lib64/libssl.so.1.0.2k
7f06ad9ea000-7f06ad9f1000 rw-p 0006b000 08:02 1614493355                 /usr/lib64/libssl.so.1.0.2k
7f06ad9f1000-7f06adc27000 r-xp 00000000 08:02 1614480434                 /usr/lib64/libcrypto.so.1.0.2k
7f06adc27000-7f06ade27000 ---p 00236000 08:02 1614480434                 /usr/lib64/libcrypto.so.1.0.2k
7f06ade27000-7f06ade43000 r--p 00236000 08:02 1614480434                 /usr/lib64/libcrypto.so.1.0.2k
7f06ade43000-7f06ade50000 rw-p 00252000 08:02 1614480434                 /usr/lib64/libcrypto.so.1.0.2k
7f06ade50000-7f06ade54000 rw-p 00000000 00:00 0 
7f06ade54000-7f06ade82000 r-xp 00000000 08:02 1610675736                 /usr/lib64/libGeoIP.so.1.5.0
7f06ade82000-7f06ae081000 ---p 0002e000 08:02 1610675736                 /usr/lib64/libGeoIP.so.1.5.0
7f06ae081000-7f06ae082000 r--p 0002d000 08:02 1610675736                 /usr/lib64/libGeoIP.so.1.5.0
7f06ae082000-7f06ae084000 rw-p 0002e000 08:02 1610675736                 /usr/lib64/libGeoIP.so.1.5.0
7f06ae084000-7f06ae0a9000 r-xp 00000000 08:02 1610672935                 /usr/lib64/libtinfo.so.5.9
7f06ae0a9000-7f06ae2a9000 ---p 00025000 08:02 1610672935                 /usr/lib64/libtinfo.so.5.9
7f06ae2a9000-7f06ae2ad000 r--p 00025000 08:02 1610672935                 /usr/lib64/libtinfo.so.5.9
7f06ae2ad000-7f06ae2ae000 rw-p 00029000 08:02 1610672935                 /usr/lib64/libtinfo.so.5.9
7f06ae2ae000-7f06ae2e5000 r-xp 00000000 08:02 1610672926                 /usr/lib64/libncursesw.so.5.9
7f06ae2e5000-7f06ae4e4000 ---p 00037000 08:02 1610672926                 /usr/lib64/libncursesw.so.5.9
7f06ae4e4000-7f06ae4e5000 r--p 00036000 08:02 1610672926                 /usr/lib64/libncursesw.so.5.9
7f06ae4e5000-7f06ae4e6000 rw-p 00037000 08:02 1610672926                 /usr/lib64/libncursesw.so.5.9
7f06ae4e6000-7f06ae4fd000 r-xp 00000000 08:02 1611806526                 /usr/lib64/libnsl-2.17.so
7f06ae4fd000-7f06ae6fc000 ---p 00017000 08:02 1611806526                 /usr/lib64/libnsl-2.17.so
7f06ae6fc000-7f06ae6fd000 r--p 00016000 08:02 1611806526                 /usr/lib64/libnsl-2.17.so
7f06ae6fd000-7f06ae6fe000 rw-p 00017000 08:02 1611806526                 /usr/lib64/libnsl-2.17.so
7f06ae6fe000-7f06ae700000 rw-p 00000000 00:00 0 
7f06ae700000-7f06ae722000 r-xp 00000000 08:02 1610613144                 /usr/lib64/ld-2.17.so
7f06ae76c000-7f06ae7ad000 rw-p 00000000 00:00 0 
7f06ae7ce000-7f06ae909000 rw-p 00000000 00:00 0 
7f06ae913000-7f06ae91a000 r--s 00000000 08:02 536890238                  /usr/lib64/gconv/gconv-modules.cache
7f06ae91a000-7f06ae91f000 r--p 00000000 08:02 1076209140                 /home/REDACTED/share/locale/de/LC_MESSAGES/goaccess.mo
7f06ae91f000-7f06ae921000 rw-p 00000000 00:00 0 
7f06ae921000-7f06ae922000 r--p 00021000 08:02 1610613144                 /usr/lib64/ld-2.17.so
7f06ae922000-7f06ae923000 rw-p 00022000 08:02 1610613144                 /usr/lib64/ld-2.17.so
7f06ae923000-7f06ae924000 rw-p 00000000 00:00 0 
7ffd657c0000-7ffd657e1000 rw-p 00000000 00:00 0                          [stack]
7ffd657fd000-7ffd657ff000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]

So now I wonder what could be the problem - can't the update handle existing database files or is the code broken? :-)

Going back to 3bce68e restores the functionality. I'll probably stick with it for a while.

allinurl commented 3 years ago

Thanks for reporting this! Are you still able to reproduce it? If you are, it would be great if you could build with --enable-debug and run it through gdb to get the full back trace bt full.

Also were you restoring a persisted database when this occurred? Thanks

dertuxmalwieder commented 3 years ago

Yes, I was (after all, I try to use GoAccess in production), so I was suspecting that there could be a relation between the persisted database and the new format. Yes, I can reproduce it.

Here's bt full:

#0  0x00007ffff68a63d7 in raise () from /lib64/libc.so.6
No symbol table info available.
#1  0x00007ffff68a7ac8 in abort () from /lib64/libc.so.6
No symbol table info available.
#2  0x00007ffff68e8f67 in __libc_message () from /lib64/libc.so.6
No symbol table info available.
#3  0x00007ffff68f0c37 in malloc_consolidate () from /lib64/libc.so.6
No symbol table info available.
#4  0x00007ffff68f120e in _int_free () from /lib64/libc.so.6
No symbol table info available.
#5  0x00000000004195f0 in kh_destroy_iglp (h=0x4db650) at src/gkhash.h:85
No locals.
#6  0x000000000041ca15 in des_iglp (h=0x4db650, free_data=1 '\001') at src/gkhash.c:360
        hash = 0x4db650
#7  0x000000000041cf84 in free_app_metrics (storage=0x4db400) at src/gkhash.c:549
        i = 5
        n = 7
        mtrc = {metric = {storem = MTRC_HITS, dbm = MTRC_LAST_PARSE}, type = MTRC_TYPE_IGLP, alloc = 0x41c424 <new_iglp_ht>, des = 0x41c9e9 <des_iglp>, del = 0x0, hash = 0x4db650, filename = 0x455e17 "IGLP_LAST_PARSE.db"}
#8  0x0000000000423fb6 in free_igdb (hash=0x4db340, k=1) at src/gkhash.c:3632
        db = 0x4db3e0
#9  0x000000000042404a in des_igdb (h=0x4db340) at src/gkhash.c:3649
        k = 1
        hash = 0x4db340
#10 0x000000000042408c in free_storage () at src/gkhash.c:3659
No locals.
#11 0x000000000042459c in house_keeping_holder () at src/goaccess.c:145
No locals.
#12 0x00000000004245b2 in house_keeping () at src/goaccess.c:153
No locals.
#13 0x00000000004246fe in cleanup (ret=0) at src/goaccess.c:216
No locals.
#14 0x000000000042848c in main (argc=137, argv=0x4cba60) at src/goaccess.c:1566
        quit = 0
        ret = 0

Note that I cannot install the missing debug information on this system - it is my webspace and it is among the very few systems where I am not root... :-) anyway, as gkhash.c is involved, I could imagine that it is indeed related to the "old" database format.

allinurl commented 3 years ago

Thanks for sharing that. I think I know what's the issue, but can I ask you to please post how did you run goaccess + which options did you use?

dertuxmalwieder commented 3 years ago

I wrote a shell script that runs it for me every ten minutes (I have not figured out yet how the server version works and I'm not impatient enough to spend more time trying), but I am gradually progressing towards moving the command-line options to the configuration file:

$HOME/bin/goaccess --log-file=$HOME/logs/webserver/access_log --agent-list --persist --restore --db-path=$HOME/goaccess.db/ --ignore-referrer=*.REDACTED.de --ignore-referrer=REDACTED.de --real-os --output=$HOME/html/stats/index.html --hide-referrer=REDACTED.de --hide-referrer=*.REDACTED.de --config-file=$HOME/goaccess.conf > /dev/null 2>&1

Other than that, my changes in the configuration file mostly involve the log format which is non-standard for the time being.

allinurl commented 3 years ago

Please rebase from https://github.com/allinurl/goaccess/commit/4da07c4f679775d540981db23e1654d5d6281242 and give it a shot again. Let me know how it goes, hopefully that addresses the issue. Thanks!

dertuxmalwieder commented 3 years ago

Looks good, no crash anymore. :-) Feel free to close this... for now.

allinurl commented 3 years ago

Awesome, glad to hear that :) and thanks for keeping up with the latest commits :+1: