eggheads / eggdrop

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

Crash Report after ".restart" (Sorry, no idea of a more specific reason) #1180

Open Casteele72 opened 3 years ago

Casteele72 commented 3 years ago

Last ten lines from my log file:

[2021071626301864T15:31:04] Module unloaded: dns
[2021071626301864T15:31:04] LANG: Section unloaded: console
[2021071626301864T15:31:04] Module unloaded: console
[2021071626301864T15:31:04] LANG: Section unloaded: assoc
[2021071626301864T15:31:04] Module unloaded: assoc
[2021071626301864T15:31:04] * Last context: tclhash.c/749 []
[2021071626301864T15:31:04] * Please REPORT this BUG!
[2021071626301864T15:31:04] * Check doc/BUG-REPORT on how to do so.
[2021071626301864T15:31:04] * Wrote DEBUG
[2021071626301864T15:31:04] * SEGMENT VIOLATION -- CRASHING!

(Sorry about the messed up timestamps, that is another problem I will figure out.)

From DEBUG:

Debug (eggdrop v1.9.1) written Wed Jul 14 15:31:04 2021
Patch level: stable
Tcl library: *unknown*
Tcl version: *unknown* (header version 8.6.9)
Tcl is threaded
Compiled with IPv6 support
Compiled with TLS support
Configure flags: '--with-handlen=32'
Compile flags: gcc -g -O2 -pipe -Wall -I.. -I..  -DHAVE_CONFIG_H -I/usr/include/tcl8.6 
Link flags: gcc 
Strip flags: touch
Context: tclhash.c/749, []
         tclhash.c/729, []
         tclhash.c/734, [Tcl proc: *isupport:server:isupport, param:  $_isupport1 $_isupport2 $_isupport3]
         tclhash.c/749, []
         tclhash.c/729, []
         tclhash.c/734, [Tcl proc: *isupport:server:isupport, param:  $_isupport1 $_isupport2 $_isupport3]
         tclhash.c/749, []
         tclhash.c/729, []
         tclhash.c/734, [Tcl proc: *isupport:server:isupport, param:  $_isupport1 $_isupport2 $_isupport3]
         tclhash.c/749, []
         tclhash.c/729, []
         tclhash.c/734, [Tcl proc: *isupport:server:isupport, param:  $_isupport1 $_isupport2 $_isupport3]
         tclhash.c/749, []
         tclhash.c/729, []
         tclhash.c/734, [Tcl proc: *isupport:server:isupport, param:  $_isupport1 $_isupport2 $_isupport3]
         tclhash.c/749 []

IDX ADDR                                     + PORT NICK               TYPE  INFO
--- ---------------------------------------- ------ ------------------ ----- ---------
5   0.0.0.0                                    1993 (telnet)           lstn  1993
-1  0.0.0.0                                       0                    lost
-1  0.0.0.0                                       0                    lost
8   127.0.0.1                                  2048 Casteele           chat  flags: cPtEp/0

Compiled without extensive memory debugging (sorry).
Open sockets: 5 (listen), 6 (file), 8, done.

This is on my home machine, so I can recompile with additional debug flags, if requested.

Also note that I made one modification to the source code: I disabled the code that checks and refuses to run as root, as I am setting this bot up as an administration toy/tool. Everything else is stock code from the downloaded .tar.gz file (except, of course, the eggdrop.conf file).

vanosg commented 3 years ago

Thanks @Casteele72 this is indeed new to us. Is it possible to chat with you on Libera to try and get a few more details from you?

Casteele72 commented 3 years ago

Yes. As an additional note, the error only occurs when I ".restart" from the party line. If I "/msg ?bot? restart ?password?" from IRC, it seems to restart without problem.

Edit: My bad, it was "/msg ?bot? rehash ?pass?" that worked, not restart. Rehashing has not had any issues.

Casteele72 commented 3 years ago

Oops... What server and channel on Libera? I did not see that info in the README (it still references FreeNode).

vanosg commented 3 years ago

I'd still like to talk to you, but that makes me think you have a Tcl script loaded that is causing the issue, as eggdrop doesn't have a 'restart' command by default :) It would still be good to understand what the script is doing though, so we see if the code it is calling is at fault or not

vanosg commented 3 years ago

irc.libera.chat #eggdrop

Casteele72 commented 3 years ago

I'm on now, as "Casteele"

Casteele72 commented 3 years ago

Latest update:

I will be uploading an eggdrop.conf (to pastebin) file that I have used to both reliably create the problem, and to avoid it. Specifically, I have been able to narrow it down to loadmodule:

  1. If loadmodule is executed in global ("::") context, the bot will restart without crashing.
  2. If loadmodule is executed in local context, the bot will crash on restart.
  3. I have not yet tried loadmodule in a namespace context, such as "namespace eval ::child {loadmodule ...}".

It does appear to be in the core code, however, and not in one of the modules. All the modules seem to successfully unload before the crash occurs. I tested this by making an event bind to dump global variables and values to the log after the "blowfish" module unloads (which was the first to load, last to unload, not counting the core eggdrop "module"). The result was that it dumped around one half of the globals and then crashed.

I have also noted some variables are not propagating correctly, even on initial load, not just a restart problem. These include {::admin} and {::nick}. {::admin} consistently becomes {} after a rehash or a non-crashing restart. The bot does not seem to even see {::nick} if I do not set it in the global namespace context.

I.E., "proc {myproc} {args} {... set ::nick mybot ...}" results in the bot complaining it does not have a nick set. But "proc {myproc} {args} {... namespace eval :: {set ::nick mybot} ...}" works as expected.

I am not certain the two issues are related, but I suspect they are--some code is not setting variable traces correctly. (It may even been in the Tcl code, not the Eggdrop code.)

Edit: pastebin of eggdrop.conf: https://pastebin.com/0CWnmWtj Comments are included to show various attempted methods.