Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2014-04-08
14:39 • Closed ticket [f3ee78aedb]: Env variables unset in slave appear to be defined bu... artifact: cf12bd1bc8 user: jan.nijtmans
2014-04-07
18:57 • Ticket [f3ee78aedb]: 5 changes artifact: 2e8a87ac91 user: dgp
17:59 • Ticket [f3ee78aedb]: 3 changes artifact: 3650cfd132 user: kevin.bowen
17:25 • Ticket [f3ee78aedb]: 3 changes artifact: 7f8f913bc2 user: dgp
2014-04-04
19:51 • New ticket [f3ee78aedb]. artifact: e05145214f user: kevin.bowen

Env variables unset in slave appear to be defined but are not accessible by master

Closed / Out of Datef3ee78aedbda6d61900893fe7f83cf0478ff1844Created 13 years agoUpdated 13 years ago
Descriptionplain2014-04-04 19:51:46
One of our engineers encountered this issue a while ago on version 8.4.6 and worked around it with the following patch. We are submitting the fix back to the user community. The patch has been updated to reference version 8.6.1.

----- Patch -----
atlgar-vdi0952[kbowen](~/workspace_remote/tcl8.6.1/generic)$ diff -du tclEnv.c.orig tclEnv.c
--- tclEnv.c.orig       2013-09-19 15:04:14.000000000 -0400
+++ tclEnv.c    2014-04-04 15:35:00.851155000 -0400
@@ -565,6 +565,7 @@
        const char *value = TclGetEnv(name2, &valueString);
 
        if (value == NULL) {
+           Tcl_UnsetVar2(interp, name1, name2, 0);
            return (char *) "no such variable";
        }
        Tcl_SetVar2(interp, name1, name2, value, 0);

----- Reproduction Script -----
#! /bin/env tclsh

set testEnvName USER

set slave [interp create]

puts "TCL Version = $tcl_version"
puts "Defined to start - $testEnvName = $env($testEnvName)"

# Execute a slave interp to unsetenv the variable
$slave eval unset env($testEnvName)

if { [info exists env($testEnvName)] == 1 } {
    # This will execute even when the environment variable has been unset.
    # This causes a de-reference error.
    puts "Still defined? - $testEnvName = $env($testEnvName)"
} else {
    puts "Not defined - $testEnvName"
}

----- Reproduction Output -----
atlgar-vdi0952[kbowen](~/workspace_remote)$ ./tcl_problem
TCL Version = 8.4
Defined to start - USER = kbowen
can't read "env(USER)": no such variable
    while executing
"puts "Still defined? - $testEnvName = $env($testEnvName)""
    invoked from within
"if { [info exists env($testEnvName)] == 1 } {
    # This will execute even when the environment variable has been unset.
    # This causes a de-refere..."
    (file "../../tcl_problem" line 13)
dgpplain2014-04-07 17:25:27
Have you tried your demo script on Tcl 8.6 ?

When I do, it no longer demonstrates the problem.

Can you clarify please?
kevin.bowenplain2014-04-07 17:59:37
Our IT staff happens to have 8.6.0 installed. Just tried it.

atlgar-vdi0952[kbowen](~/workspace_remote)$ /tools/pandora64/.package/tcltk-8.6.0/bin/tclsh8.6  ./tcl_problem
TCL Version = 8.6
Defined to start - USER = kbowen
no such variable
    (read trace on "env(USER)")
    invoked from within
"puts "Still defined? - $testEnvName = $env($testEnvName)""
    invoked from within
"if { [info exists env($testEnvName)] == 1 } {
    # This will execute even when the environment variable has been unset.
    # This causes a de-refere..."
    (file "./tcl_problem" line 13)
dgpplain2014-04-07 18:57:54
OK, I bisected and found that since

checkout:     bac3f9b1394f8eebc83f67a57948a6f4d68dcaf0 2013-11-20 11:20:32 UTC

the problem has been resolved on the development trunk,
so Tcl 8.6.2 should be ok.  Assigning to jan.nijtmans
in case there's any more to say.
jan.nijtmanswiki2014-04-08 14:39:31

The hard work fixing tracing the "env" array was done earlier by dkf in [afaff33553].

This broke the win32 test-suite, apparently because dkf's work exposed the bug described in this ticket. That's what I fixed in [bac3f9b139]

So, if everything is fixed, I have nothing more to say! Closing.

Log in (anonymous is fine) to add a comment.