Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2010-07-26
05:23 • Closed ticket [3033206fff]: lib/ttrace.tcl uses ::version as temporary variable<... artifact: bcf6b6fa96 user: dkf
2010-07-22
19:39 • New ticket [3033206fff]. artifact: 481a254e60 user: thommey

lib/ttrace.tcl uses ::version as temporary variable

Closed / Fixed3033206fffffffffffffffffffffffffffffffffCreated 16 years agoUpdated 16 years ago
Descriptionplain2010-07-22 19:39:27
The thread package includes lib/ttrace.tcl - loaded by [package require Ttrace] - uses $::version to temporarily store the result of [package require Thread] in a catch ("catch {package require Thread} version"). This global variable is unfortunately very likely to be used by applications (embedders mostly?) to hold their own version number. Eggdrop, for example, protects that variable as read-only with a write trace, causing [package require Ttrace] to fail because it can't write to that variable (and even if it could, it would overwrite Eggdrops version number and existing Tcl scripts for Eggdrop rely on it).
I'd suggest changing it to anything else or a namespace variable.
dkfplain2010-07-26 05:23:42
allow_comments - 1

Oh, that's Tcl's variable resolution rules. Yuck. Luckily in this case there's a way to write things that avoids the nastiness, changing (effectively) this:

    if {![catch {package require Thread} version]} {
        variable tvers $version
        ...
    }

into this:

    if {![catch {
        variable tvers [package require Thread]
    }]} {
        ...
    }

That version is hazard-free.
Log in (anonymous is fine) to add a comment.