eggheads / eggdrop

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

egg-1.9.4-git crash with namespace delete ::? #1389

Closed ZarTek-Creole closed 1 year ago

ZarTek-Creole commented 1 year ago
if { ![namespace exists ::PECHO] } {
    namespace eval ::PECHO {}
} else {
    putlog "Désallocation des ressources de [namespace current]"
    foreach binding [lsearch -inline -all -regexp [binds *[set ns [::tcl::string::range [namespace current] 2 end]]*] " \{?(::)?$ns"] {
        unbind [lindex $binding 0] [lindex $binding 1] [lindex $binding 2] [lindex $binding 4]
    }
    foreach running_timer [timers] {

        if { [::tcl::string::match "*[namespace current]::*" [lindex $running_timer 1]] } { killtimer [lindex $running_timer 2] }
    }
    foreach running_utimer [utimers] {
        if { [::tcl::string::match "*[namespace current]::*" [lindex $running_utimer 1]] } { killutimer [lindex $running_utimer 2] }
    }
    namespace delete [namespace current]
    namespace eval ::PECHO {}
}
[11:59:49] Désallocation des ressources de ::
[11:59:49] * Last context: tclhash.c/743 []
[11:59:49] * Please REPORT this BUG!
[11:59:49] * Check doc/BUG-REPORT on how to do so.
[11:59:49] * Wrote DEBUG
[11:59:49] * SEGMENT VIOLATION -- CRASHING!

By accident my script tried to delete the namespace "::" which caused a crash.

I know we shouldn't, it's normal. Only, I don't think it's normal for tclhash.c/743 to crash. I don't know if you can put a warning when trying this, or otherwise fix the tclhash?


I obviously corrected my code

if { ![namespace exists ::PECHO] } {
    namespace eval ::PECHO {}
} else {
    set ns ::PECHO
    putlog "Désallocation des ressources de ${ns}"
    foreach binding [lsearch -inline -all -regexp [binds *[set ns [::tcl::string::range ${ns} 2 end]]*] " \{?(::)?$ns"] {
        unbind [lindex $binding 0] [lindex $binding 1] [lindex $binding 2] [lindex $binding 4]
    }
    foreach running_timer [timers] {

        if { [::tcl::string::match "*${ns}::*" [lindex $running_timer 1]] } { killtimer [lindex $running_timer 2] }
    }
    foreach running_utimer [utimers] {
        if { [::tcl::string::match "*${ns}::*" [lindex $running_utimer 1]] } { killutimer [lindex $running_utimer 2] }
    }
    namespace delete ${ns}
    namespace eval ${ns} {}
}
ZarTek-Creole commented 1 year ago

DEBUG

Debug (eggdrop v1.9.4+logupdates) written Sat Jan 21 15:08:16 2023
Patch level: logupdates
Tcl library: /usr/share/tcltk/tcl8.6
Tcl version: 8.6.13 (header version 8.6.13)
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: main.c/1043, []
         main.c/1043, []
         main.c/1043, []
         main.c/1043, []
         main.c/1043, []
         main.c/1043, []
         main.c/1043, []
         main.c/1043, []
         main.c/1043, []
         main.c/1043, []
         main.c/1043, []
         main.c/1043, []
         main.c/1043, []
         main.c/1043, []
         tclhash.c/219, []
         tclhash.c/247 []

IDX ADDR                                     + PORT NICK      TYPE  INFO
--- ---------------------------------------- ------ --------- ----- ---------
5   0.0.0.0                                    8888 (telnet)  lstn  8888

Not logging file main.c!
File 'language.c' accounted for 20478/20478 (ok)
File 'chanprog.c' accounted for 0/0 (ok)
File 'misc.c    ' accounted for 46082/46082 (ok)
File 'userrec.c ' accounted for 0/0 (ok)
File 'net.c     ' accounted for 0/0 (ok)
File 'dccutil.c ' accounted for 1016/1016 (ok)
File 'botnet.c  ' accounted for 0/0 (ok)
File 'tcl.c     ' accounted for 3216/7000 (debug follows:)
   351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   933 :(0016) 933 :(0016) 852 :(0016) 852 :(0016) 852 :(0016)
   852 :(0016) 852 :(0016) 852 :(0016) 852 :(0016) 852 :(0016)
   852 :(0016) 852 :(0016) 852 :(0016) 852 :(0016) 852 :(0016)
   852 :(0016) 852 :(0016) 852 :(0016) 852 :(0016) 852 :(0016)
   852 :(0016) 852 :(0016) 852 :(0016) 852 :(0016) 852 :(0016)
   852 :(0016) 852 :(0016) 852 :(0016) 852 :(0016) 852 :(0016)
   852 :(0016) 852 :(0016) 852 :(0016) 852 :(0016) 852 :(0016)
   892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016)
   892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016)
   892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016)
   892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016)
   892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016)
   892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016)
   892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016)
   892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016)
   892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016)
   892 :(0016) 892 :(0016) 892 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 319 :(0040) 892 :(0016) 892 :(0016) 852 :(0016)
   852 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 852 :(0016) 852 :(0016)
   852 :(0016) 892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016)
   892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016)
   892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016)
   892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016)
   892 :(0016) 892 :(0016) 933 :(0016) 933 :(0016) 933 :(0016)
   933 :(0016) 933 :(0016) 933 :(0016) 933 :(0016) 933 :(0016)
   933 :(0016) 933 :(0016) 933 :(0016) 933 :(0016) 933 :(0016)
   933 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 852 :(0016) 852 :(0016) 852 :(0016)
   852 :(0016) 852 :(0016) 852 :(0016) 852 :(0016) 852 :(0016)
   852 :(0016) 852 :(0016) 852 :(0016) 852 :(0016) 892 :(0016)
   892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016)
   892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016)
   892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016)
   892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016)
   892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016)
   892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016)
   892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016)
   933 :(0016) 933 :(0016) 852 :(0016) 892 :(0016) 892 :(0016)
   892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016)
   892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016)
   892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016)
   892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016) 892 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016) 351 :(0016)
   351 :(0016) 351 :(0016) 351 :(0016) 892 :(0016) 892 :(0016)
   892 :(0016)
File 'tclhash.c ' accounted for 31067/31067 (ok)
File 'tclmisc.c ' accounted for 19/19 (ok)
File 'modules.c ' accounted for 907/907 (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 'console   ' accounted for 0/0 (ok)
Module 'irc       ' accounted for 0/0 (ok)
Module 'server    ' accounted for 873/873 (ok)
Module 'channels  ' accounted for 7464/7464 (ok)
Module 'encryption' 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), 6 (file), done.