Tcl Source Code

View Ticket
Login
Ticket UUID: 502197
Title: SetEnvironmentVariable() currupts list
Type: Bug Version: obsolete: 8.5a0
Submitter: davygrvy Created on: 2002-01-11 05:42:31
Subsystem: 08. Environment Variables Assigned To: patthoyts
Priority: 5 Medium Severity:
Status: Open Last Modified: 2005-11-04 04:56:05
Resolution: None Closed By: davygrvy
    Closed on: 2002-02-25 22:16:32
Description:
Win32 specific!

Use of SetEnvironmentVariable() by an extension or an 
application that embeds Tcl, puts the libc maintained 
environ list out-of-sync.  This in turn puts Tcl's env 
array out-of-sync as well.
User Comments: hobbs added on 2005-10-05 15:10:19:
Logged In: YES 
user_id=72656

Hmmm, I just corrected this for unix with 979640.  I'm not
sure how related they are, as we rely on putenv solely for
Windows.

davygrvy added on 2004-01-15 16:19:41:
Logged In: YES 
user_id=7549

Just this, and everyone has the wrong answer:

% getenv FOO
% setenv FOO qwe
% set env(FOO)
baz
% wgetenv FOO
qwe
% tgetenv FOO
baz
% wsetenv FOO asd             <- system
% tgetenv FOO
baz                           <- tcl
% getenv FOO
qwe                           <- c-runtime
%

davygrvy added on 2004-01-15 15:58:00:

File Added - 73512: test.c

davygrvy added on 2004-01-15 15:57:59:
Logged In: YES 
user_id=7549

writing sync problems:

% tsetenv FOO baz
% wgetenv FOO
baz
% set env(FOO)
baz
% getenv FOO                          <- blank return
% wsetenv FOO pickle
% set env(FOO)
baz
% getenv FOO
%

reading sync prolems:

% set env(TEST) first
first
% load test
% set env(TEST) second
second
% getenv TEST
first
% wgetenv TEST
second
% tgetenv TEST
second

davygrvy added on 2004-01-03 16:39:34:
Logged In: YES 
user_id=7549

This is not fixed, nor invalid.  reopening.

davygrvy added on 2002-02-26 05:16:32:
Logged In: YES 
user_id=7549

but in places where this is out of your control, 
GetEnvironmentStrings() more accurately represents what the 
OS maintains.

hobbs added on 2002-02-26 05:09:16:
Logged In: YES 
user_id=72656

This is why Tcl has the Tcl_PutEnv compatibility procedure 
for extension authors to use to keep in sync.

Attachments: