Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2001-03-14
07:38 • Ticket [405769ffff] rare segfault at "unset -nocomplain" status st... artifact: b1e1e5a0a7 user: dgp
2001-03-07
01:43 • Ticket [405769ffff]: 7 changes artifact: af4204fcb8 user: dgp
2001-03-06
21:47 • Closed ticket [405769ffff]. artifact: a96e2c1e3a user: dkf
2001-03-05
19:58 • Ticket [405769ffff]: 5 changes artifact: 9f53570f04 user: msofer
18:54 • Ticket [405769ffff]: 1 change artifact: d24a0bf361 user: msofer
17:19 • Ticket [405769ffff]: 1 change artifact: 8dff685bab user: dkf
2001-03-04
11:10 • Ticket [405769ffff]: 5 changes artifact: 3e0e1c2e93 user: msofer
03:46 • New ticket [405769ffff]. artifact: e92507d3ea user: msofer

rare segfault at "unset -nocomplain"

Closed / Fixed405769ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2001-03-04 03:46:48
The command
   unset -nocomplain
(with no further arguments) causes Tcl_UnsetObjCmd (in
tclVar.c) to request the string representation of an
object which was *not* passed as an argument. 

Under special circumstances (which I couldn't trigger
in current sources) this causes a segfault. In order to
cause a segfault,   
    *(stackPtr(stackTop+1)->bytes)
must be in a forbidden memory region at the moment of
the invocation of "unset -nocomplain".

The cure seems pretty harmless: remove the offending
line, which is unused anyway. The offending statement
(line 2627 in tclVar.c) reads:
     name = TclGetString(objv[i]);

Thusly corrected sources pass all tcltests.
msoferplain2001-03-04 11:10:15
Logged In: YES 
user_id=148712

Forgot a detail: this also cures the following behaviour,
which is not in agreement with the man page for unset (and
hence is a bug):

[mig@ant bin2]$ tclsh8.4 
% set -- 1
1
% unset -nocomplain --
% set --
1
dkf Ticket [405769ffff]: 1 change [History diff]2001-03-05 17:19:53
msofer Ticket [405769ffff]: 1 change [History diff]2001-03-05 18:54:09
msoferplain2001-03-05 19:58:49
Logged In: YES 
user_id=148712

The following scriptlet (thanks to Donal Fellows!) exercises
the bug and produces a segfault on my setup (RH 6.2):

  proc spotbug {-nocomplain} {
      unset -nocomplain
      spotbug -nocomplain
  }
  spotbug -nocomplain
dkf Closed ticket [405769ffff]. [History diff]2001-03-06 21:47:19
dgpplain2001-03-07 01:43:26
Logged In: YES 
user_id=80530

The SYNOPSIS for [unset] now says:

   unset ?-nocomplain? ?--? ?name name ...?

The command [unset] matches that synopsis, but fails:

% unset
wrong # args: should be "unset ?-nocomplain? ?--? ?varName
varName ...?

Shouldn't [unset] be a successful no-op?
dgpplain2001-03-14 07:38:01
Logged In: YES 
user_id=80530

Thanks for making [unset] legal!

Now test set-old-7.2 needs to be updated to recognize
the newly legal [unset] with no arguments.
Log in (anonymous is fine) to add a comment.