eggheads / eggdrop

The Eggdrop IRC Bot
GNU General Public License v2.0
504 stars 84 forks source link

Twitch bot crashes on rehash and restart #1263

Closed roughnecks closed 2 years ago

roughnecks commented 2 years ago

Hello,

I have set up a Twitch Bot which connects and works alright, but whenever I issue a .rehash or .restart command from telnet, it crashes.

** roughnecks joined the party line. .rehash [14:32:09] #roughnecks# rehash Rehashing. [14:32:09] Rehashing ... [14:32:09] Listening for telnet connections on 0.0.0.0 port 36765 (all). [14:32:09] Tcl error in file twitch.conf: [14:32:09] Read-only variable (write trace on "keep-nick") invoked from within "set keep-nick 1" (file "twitch.conf" line 1203) [14:32:09] CONFIG FILE NOT LOADED (NOT FOUND, OR ERROR) Connection closed by foreign host.

Running eggdrop 1.9.1 on Debian Bullseye

Thanks

Lord255 commented 2 years ago

hello!

i could reproduce the same as mentioned above. some more details below.

info: -using develop version, cloned on 06feb2022 -using no configuration paramters ( -> ./configure)

so two things:

1, bot dies on .rehash

[20:00:27] #Lord255# status
I am __redacted-nickname__, running eggdrop v1.9.2+alpha: 1 user (mem: 16207k).
Online for 00:00 (background) - CPU: 00:00.02 - Cache hit: 37.5%
Configured with:
Admin: Lord255
Config file: confs/egg_twitch___redacted-nickname__.conf
OS: Linux 5.10.60.1-microsoft-standard-WSL2
Process ID: 303 (parent 12)
Tcl library: /usr/share/tcltk/tcl8.6
Tcl version: 8.6.10 (header version 8.6.10)
Tcl is threaded.
TLS support is enabled.
TLS library: OpenSSL 1.1.1f  31 Mar 2020
IPv6 support is enabled.
Threaded DNS core is enabled.
Socket table: 20/100
Memory table: 3435/4096 (83.9% full)
Memory fault: only accounting for 16596805/16644445 (99.7%)
Memory table itself occupies an additional 160k static
Loaded module information:
    Channels: #redacted-channel (need ops)
    Account tracking: Disabled
      (Missing capabilities: use-354 extended-join account-notify)
    Online as: __redacted-nickname__!__redacted-nickname__@__redacted-nickname__.tmi.twitch.tv (__redacted-nickname__)
    Connected to (null) [irc.chat.twitch.tv]:6667 (connected for 00:00)
    Active CAP negotiations: twitch.tv/membership twitch.tv/tags twitch.tv/commands
    #redacted-channel            :   1 member, enforcing "+tn" (greet)

------

[20:02:04] tcl: builtin dcc call: *dcc:rehash Lord255 9
[20:02:04] #Lord255# rehash
Rehashing.
[20:02:04] Writing user file...
[20:02:03] Writing channel file...
[20:02:03] Rehashing ...
[20:02:03] Writing channel file...
[20:02:03] Listening for telnet connections on 0.0.0.0 port 7792 (users).
[20:02:03] Tcl error in file 'confs/egg_twitch___redacted-nickname__.conf':
[20:02:03] Read-only variable
    (write trace on "keep-nick")
    invoked from within
"set keep-nick 1"
    (file "confs/egg_twitch___redacted-nickname__.conf" line 1220)
[20:02:03] * CONFIG FILE NOT LOADED (NOT FOUND, OR ERROR)
Connection closed by foreign host.

------

$ grep -i twitch confs/egg_twitch___redacted-nickname__.conf
logfile mco * "logs/egg_twitch___redacted-nickname__.log"
set userfile "confs/botfiles/egg_twitch___redacted-nickname__.user"
set pidfile "confs/pids/pid.egg_twitch___redacted-nickname__"
#set ssl-privatekey "confs/tls/egg_twitch___redacted-nickname__.key"
#set ssl-certificate "confs/tls/egg_twitch___redacted-nickname__.crt"
set chanfile "confs/botfiles/egg_twitch___redacted-nickname__.chan"
##   Twitch (This requires twitch.mod to be loaded as well)
set net-type "Twitch"
server add irc.chat.twitch.tv 6667 oauth:<redacted_oauth>
#### TWITCH MODULE ####
# This module attempts to provide connectivity with the Twitch gaming platform.
# While Twitch provides an IRC gateway to connect with it's streaming service,
# for additional information. Only load this if you are connecting to Twitch!
# Please see doc/TWITCH for Twitch-specific setup information, like how to
loadmodule twitch
set notefile "confs/botfiles/egg_twitch___redacted-nickname__.notes"

------------------------------------------------

2, bot crashes on .restart

[20:05:34] tcl: builtin dcc call: *dcc:restart Lord255 7
[20:05:34] #Lord255# restart
Restarting.
[20:05:34] Writing user file...
[20:05:34] Writing channel file...
[20:05:34] Restarting ...
[20:05:34] Module unloaded: seen
[20:05:34] LANG: Section unloaded: console
[20:05:34] Module unloaded: console
[20:05:34] LANG: Section unloaded: notes
[20:05:34] Module unloaded: notes
[20:05:34] De-Allocated bind table ccht
[20:05:34] De-Allocated bind table cmsg
[20:05:34] De-Allocated bind table htgt
[20:05:34] De-Allocated bind table wspr
[20:05:34] De-Allocated bind table wspm
[20:05:34] De-Allocated bind table rmst
[20:05:34] De-Allocated bind table usst
[20:05:34] De-Allocated bind table usrntc
[20:05:34] Module unloaded: twitch
[20:05:34] De-Allocated bind table topc
[20:05:34] De-Allocated bind table splt
[20:05:34] De-Allocated bind table sign
[20:05:34] De-Allocated bind table rejn
[20:05:34] De-Allocated bind table part
[20:05:34] De-Allocated bind table nick
[20:05:34] De-Allocated bind table mode
[20:05:34] De-Allocated bind table kick
[20:05:34] De-Allocated bind table invt
[20:05:34] De-Allocated bind table join
[20:05:34] De-Allocated bind table pubm
[20:05:34] De-Allocated bind table pub
[20:05:34] De-Allocated bind table need
[20:05:34] De-Allocated bind table ircaway
[20:05:34] De-Allocated bind table monitor
[20:05:34] Module unloaded: irc
[20:05:34] Module unloaded: ctcp
[20:05:34] De-Allocated bind table isupport
[20:05:34] De-Allocated bind table wall
[20:05:34] De-Allocated bind table account
[20:05:34] De-Allocated bind table raw
[20:05:34] De-Allocated bind table rawt
[20:05:34] De-Allocated bind table notc
[20:05:34] De-Allocated bind table msgm
[20:05:34] De-Allocated bind table msg
[20:05:34] De-Allocated bind table flud
[20:05:34] De-Allocated bind table ctcr
[20:05:34] De-Allocated bind table ctcp
[20:05:34] De-Allocated bind table out
[20:05:34] Module unloaded: server
[20:05:34] Writing channel file...
[20:05:34] Module unloaded: channels
[20:05:34] * Last context: twitch:twitch.c/825 []
[20:05:34] * Please REPORT this BUG!
[20:05:34] * Check doc/BUG-REPORT on how to do so.
[20:05:34] * Wrote DEBUG
[20:05:34] * SEGMENT VIOLATION -- CRASHING!
Connection closed by foreign host.

.status can be seen above, for the .rehash issue.

Lord255 commented 2 years ago

the .restart made a core file

Reading symbols from eggdrop...

warning: core file may not match specified executable file.
[New LWP 753]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `./eggdrop confs/egg_twitch___redacted-nickname__.conf'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:65
65      ../sysdeps/x86_64/multiarch/strlen-avx2.S: No such file or directory.
(gdb) bt
#0  __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:65
#1  0x00007f1181b4204a in Tcl_NewStringObj () from /lib/x86_64-linux-gnu/libtcl8.6.so
#2  0x00007f1181b599f7 in Tcl_SetVar2 () from /lib/x86_64-linux-gnu/libtcl8.6.so
#3  0x000055df38e10827 in tcl_eggstr (cdata=0x55df3a70b3d0, irp=<optimized out>, name1=0x55df3a798340 "::cap-request", name2=0x0, flags=449) at tcl.c:262
#4  0x00007f1181b510f4 in TclCallVarTraces () from /lib/x86_64-linux-gnu/libtcl8.6.so
#5  0x00007f1181b5a99b in ?? () from /lib/x86_64-linux-gnu/libtcl8.6.so
#6  0x00007f1181b5e016 in ?? () from /lib/x86_64-linux-gnu/libtcl8.6.so
#7  0x00007f1181b26886 in TclTeardownNamespace () from /lib/x86_64-linux-gnu/libtcl8.6.so
#8  0x00007f1181a5e5c1 in ?? () from /lib/x86_64-linux-gnu/libtcl8.6.so
#9  0x000055df38e05705 in mainloop (toplevel=<optimized out>) at ./main.c:969
#10 0x000055df38dda8ca in main (arg_c=<optimized out>, arg_v=<optimized out>) at ./main.c:1297

DEBUG file in case if its needed:

$ cat DEBUG
Debug (eggdrop v1.9.2+alpha) written Thu Feb 24 20:19:06 2022
Patch level: alpha
Tcl library: *unknown*
Tcl version: *unknown* (header version 8.6.10)
Tcl is threaded
Compiled with IPv6 support
Compiled with TLS support
Configure flags: none
Compile flags: gcc -g -O2 -pipe -Wall -I.. -I..  -DHAVE_CONFIG_H -I/usr/include/tcl8.6 -g3 -DDEBUG -DDEBUG_ASSERT -DDEBUG_MEM -DDEBUG_DNS
Link flags: gcc -lpthread
Strip flags: touch
Context: tclhash.c/729, []
         tclhash.c/734, [Tcl proc: <null>, param:  $_raw1 $_raw2 $_raw3]
         tclhash.c/749, []
         tclhash.c/729, []
         tclhash.c/734, [Tcl proc: *chon:console:chon, param:  $_chonof1 $_chonof2]
         tclhash.c/749, []
         tclhash.c/729, []
         tclhash.c/734, [Tcl proc: *chon:notes, param:  $_chonof1 $_chonof2]
         tclhash.c/749, []
         tclhash.c/729, []
         tclhash.c/734, [Tcl proc: *chon:channels:chon, param:  $_chonof1 $_chonof2]
         tclhash.c/749, []
         tclhash.c/729, []
         tclhash.c/734, [Tcl proc: *dcc:restart, param:  $_dcc1 $_dcc2 $_dcc3]
         tclhash.c/749, []
         twitch:twitch.c/825 []

IDX ADDR                                     + PORT NICK      TYPE  INFO
--- ---------------------------------------- ------ --------- ----- ---------
5   0.0.0.0                                    7792 (users)   lstn  7792
-1  0.0.0.0                                       0           lost
7   127.0.0.1                                 34682 Lord255   chat  flags: cpTEp/0

Not logging file main.c!
File 'language.c' accounted for 22636/22636 (ok)
File 'chanprog.c' accounted for 0/0 (ok)
File 'misc.c    ' accounted for 16518450/16518450 (ok)
File 'userrec.c ' accounted for 400/400 (ok)
File 'net.c     ' accounted for 0/0 (ok)
File 'dccutil.c ' accounted for 5824/5824 (ok)
File 'botnet.c  ' accounted for 0/0 (ok)
File 'tcl.c     ' accounted for 64/248 (debug follows:)
   351 :(0016) 892 :(0016) 892 :(0016) 852 :(0016) 319 :(0040)
   852 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
File 'tclhash.c ' accounted for 0/0 (ok)
File 'tclmisc.c ' accounted for 32/32 (ok)
File 'modules.c ' accounted for 411/411 (ok)
File 'tcldcc.c  ' accounted for 16/16 (ok)
File 'dns.c     ' accounted for 0/0 (ok)
File 'tls.c     ' accounted for 0/0 (ok)
Module 'uptime    ' accounted for 0/0 (ok)
Module 'encryption2' accounted for 0/0 (ok)
Module 'eggdrop   ' accounted for 0/0 (ok)
--- End of debug memory list.
Open sockets: 5 (listen), 8 (file), 7, done.
michaelortmann commented 2 years ago

maybe we need to rem_tcl_strings(my_tcl_strings) in https://github.com/eggheads/eggdrop/blob/41a03be22281e3abb2a3d202434533bf6a0f5874/src/mod/twitch.mod/twitch.c#L823-L841 ?

Lord255 commented 2 years ago

@michaelortmann if i add the mentioned line to twitch.c like this:

static char *twitch_close()
{
  Context;
  rem_builtins(H_dcc, mydcc);
  rem_builtins(H_raw, twitch_raw);
  rem_builtins(H_rawt, twitch_rawt);
  rem_tcl_commands(mytcl);
  rem_tcl_strings(my_tcl_strings);
  rem_tcl_ints(my_tcl_ints);
  del_bind_table(H_ccht);
  del_bind_table(H_cmsg);
  del_bind_table(H_htgt);
  del_bind_table(H_wspr);
  del_bind_table(H_wspm);
  del_bind_table(H_rmst);
  del_bind_table(H_usst);
  del_bind_table(H_usrntc);
  module_undepend(MODULE_NAME);
  return NULL;
}

.restart works. :)


.rehash though still makes the bot crash

Lord255 commented 2 years ago

for the .rehash issue: setting keep-nick to 0

set keep-nick 0

does not help.

[23:04:52] Read-only variable
    (write trace on "keep-nick")
    invoked from within
"set keep-nick 0"
    (file "confs/egg_twitch_<redacted>.conf" line 1220)
[23:04:52] * CONFIG FILE NOT LOADED (NOT FOUND, OR ERROR)

however, commenting it out, works.

$ grep "keep-nick" confs/egg_twitch_<redacted>.conf
#set keep-nick 1

--------------------------------------------

since twitch does not use/care with nick changes, that can be just set to zero, or something. or we should just mention in the conf, that if twitch is enabled, that should be commented out. @roughnecks : you can comment out keep-nick, that will solve the .rehash issue for now. the .restart issue is getting fixed by michael, but see above the suggestion - that solved the .restart issue. :)

roughnecks commented 2 years ago

yeah, commenting the "keep-nick" line works for rehashing - haven's tried the solution for restarting tho.

Thanks