Threads with eggdrop #61

thommey opened this Issue Jul 22, 2010 · 6 comments

1 participant

Eggheads member
Trac Data
Ticket 61
Reported by Ofloo
Status closed
Component Core
Priority major
Milestone 1.6.20
Version 1.6.20

tcl version 8.5 threads

[14:21:15] #Ofloo# set errorInfo
Currently: couldn't save command result in variable
Currently: while executing
Currently: "catch {package require Thread} version"
Currently: (in namespace eval "::ttrace" script line 9)
Currently: invoked from within
Currently: "namespace eval ttrace {
Currently: # Setup some compatibility wrappers
Currently: if {[info commands nsv_set] != ""} {
Currently: variable tvers 0
Currently: variable mu..."
Currently: (file "/usr/local/lib/thread2.6.5/ttrace.tcl" line 47)
Currently: invoked from within
Currently: "source [file join $dir ttrace.tcl]"
Currently: (procedure "thread_source" line 8)
Currently: invoked from within
Currently: "thread_source /usr/local/lib/thread2.6.5"
Currently: ("package ifneeded Ttrace 2.6.5" script)
Currently: invoked from within
Currently: "package require Ttrace"
.tcl catch {package require Thread} version
Tcl error: couldn't save command result in variable
.tcl catch
Tcl error: wrong # args: should be "catch script ?resultVarName? ?optionVarName?"
.tcl catch {package require Thread} vers

Tcl: 0
.set version
[14:25:16] #Ofloo# set version
Currently: 1.6.20+RC2 1062003 PRE-RELEASE 1279200246 RC2

the problem is that when you package require Ttrace which is part of threads it tries to overwrite the version variable, .. if this is loaded from a script the bot will crash and core

the exact problem is the variable name, both Ttrace and eggdrop are makeing use of this variable.

Eggheads member

Comment by Ofloo
file tcl.c

static tcl_strings def_tcl_strings[] = {
{"botnet-nick", botnetnick, HANDLEN, 0},
{"userfile", userfile, 120, STR_PROTECT},
{"motd", motdfile, 120, STR_PROTECT},
{"admin", admin, 120, 0},
{"help-path", helpdir, 120, STR_DIR | STR_PROTECT},
{"temp-path", tempdir, 120, STR_DIR | STR_PROTECT},
{"text-path", textdir, 120, STR_DIR | STR_PROTECT},
#ifndef STATIC
{"mod-path", moddir, 120, STR_DIR | STR_PROTECT},
{"notify-newusers", notify_new, 120, 0},
{"owner", owner, 120, STR_PROTECT},
{"my-ip", myip, 120, 0},
{"my-hostname", hostname, 120, 0},
{"network", network, 40, 0},
{"whois-fields", whois_fields, 1024, 0},
{"nat-ip", natip, 120, 0},
{"username", botuser, 10, 0},
{"version", egg_version, 0, 0},
{"firewall", firewall, 120, 0},
{"config", configfile, 0, 0},
{"telnet-banner", bannerfile, 120, STR_PROTECT},
{"logfile-suffix", logfile_suffix, 20, 0},
{"timestamp-format",log_ts, 32, 0},
{"pidfile", pid_file, 120, STR_PROTECT},
{NULL, NULL, 0, 0}

{"version", egg_version, 0, 0},
{"versions", egg_version, 0, 0},
and it works, however then the variable version doesn't exist anymore, but it is changed into versions instead.

weird that it works in the same namespace/scope

Eggheads member

Comment by @thommey
This is indeed caused by Tcl's Thread package (lib/ttrace.tcl) using the global variable $version as a temporary variable. That's surely a bug on their side, because they do not need a variable that is this likely to be used just as a temporary one. I filed a bug at Tcl's sourceforge bugtracker with that: here.
We cannot change our version variable to be writable or rename it because existing Tcl scripts rely on it and it makes perfect sense to accompany a global $version variable (other applications do that too - aMSN for example).

So the only fix is for you to modify lib/ttrace.tcl to use another variable name there.

Eggheads member

Comment by Ofloo
ok add "variable version" right after "namespace eval ttrace {" that should take care of it, without having to change any of the code.

Eggheads member

Comment by Ofloo
sorry don't know how to reply at

Eggheads member

Comment by Ofloo
here's a patch if you could be so kind to post it to ttrace on sf

--- ttrace.tcl 2010-07-25 01:46:47.000000000 +0200
+++ ttrace.tcl 2010-07-25 01:43:53.000000000 +0200
@@ -46,6 +46,7 @@

namespace eval ttrace {

  • variable version # Setup some compatibility wrappers if {[info commands nsv_set] != ""} { variable tvers 0
Eggheads member

Comment by pseudo
Fixed in ttrace.tcl

@thommey thommey closed this Oct 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment