Skip to content
Tcl Source Code History Of Ticket 218497
Login

History Of Ticket 218497

Artifacts Associated With Ticket 218497

  1. Ticket change [ac81e20390] (rid 101305) by nobody on 2000-10-26 01:01:20:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      OriginalBugID: 719 Bug
      Version: 8.0.3
      SubmitDate: '1998-10-13'
      LastModified: '1999-12-03'
      Severity: SER
      Status: Released
      Submitter: admin
      ChangedBy: hobbs
      OS: Solaris
      OSVersion: NA
      Machine: NA
      FixedDate: '1999-12-03'
      FixedInVersion: 8.2
      ClosedDate: '2000-10-25'
      
      
      Synopsis: Tcl_ObjSetVar2(..., TCL_LEAVE_ERR_MSG) clears interp->result
      when new variable is created
      
      ReproducibleScript:  /*
       * Demo program for bug in Tcl_ObjSetVar2() Tcl 8.0, 8.0p1, 8.0p2 and 8.0.3
       *
       * Really bug in TclLookupVar() on line 214 of tclVar.c where
       * Tcl_ResetResult() is called even though the variable creation
       * may yet succeed!
       */
      #include <stdio.h>
      #include <tcl.h>
      
      #define MAKE_OBJ(name, val)  Tcl_Obj *name = Tcl_NewStringObj(val, sizeof(val)-1)
      
      static int AppInit(Tcl_Interp *interp)
      {
          int ok;
          MAKE_OBJ(obj, "newVar");
          MAKE_OBJ(cmdObj, "list 1 + 2 + 3");
      
          if (Tcl_Init(interp) != TCL_OK)
              return TCL_ERROR;
      
          /*
           * Breaks the first time when variable needs to be created!
           */
          if (Tcl_EvalObj(interp, cmdObj) != TCL_OK)
              return TCL_ERROR;
      
          if (Tcl_ObjSetVar2(interp, obj, NULL, Tcl_GetObjResult(interp),
                             TCL_PARSE_PART1|TCL_LEAVE_ERR_MSG) == NULL)
              return TCL_ERROR;
      
          if (Tcl_VarEval(interp, "puts -nonewline {Value is empty: }\n",
                           "puts '$newVar'\n", (char *)0) != TCL_OK)
              return TCL_ERROR;
      
          /*
           * Works the second time when variable already exists!
           */
          if (Tcl_EvalObj(interp, cmdObj) != TCL_OK)
              return TCL_ERROR;
      
          if (Tcl_ObjSetVar2(interp, obj, NULL, Tcl_GetObjResult(interp),
                             TCL_PARSE_PART1|TCL_LEAVE_ERR_MSG) == NULL)
              return TCL_ERROR;
      
          if (Tcl_VarEval(interp, "puts -nonewline {Value is correct: }\n",
                           "puts '$newVar'\n", (char *)0) != TCL_OK)
              return TCL_ERROR;
      
          return Tcl_VarEval(interp, "exit 0", (char *)0);
      }
      
      int main(int argc, char *argv[])
      {
          Tcl_Main(argc, argv, AppInit);
          return 1;
      }
      
      ObservedBehavior: Creation of new variables with TCL_LEAVE_ERR_MSG
      clobbers interpreter result even when variable creation succeeds.  I
      do not believe this matches the desired semantics.
      
      DesiredBehavior: The interpreter result should be modified only on
      error.
      
      Patch: I do not have a patch that I am sure will work.  The bug is on
      line 214 of tclVar.c where Tcl_ResetResult(interp) is called before
      the variable creation is attempted.  I think this code could be moved
      lower or removed... but the implications for the functions called to
      create the variable are not clear to me.
      
      Comments: Cropped up while trying to fix "catch" to report a proper
      error message when unable to set result variables.  The current
      generic message is also a bug, trivial to fix if it were not for the
      SetVar2 problem.
      
      
      
      Tcl_ResetResult is not called at all in TclLookupVar as of 8.2. 
      -- 12/03/1999 hobbs
      
    4. foundin initialized to: "obsolete: 8.0.3"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "nobody"
    9. subsystem initialized to: "10. Objects"
    10. title initialized to:
      Tcl_ObjSetVar2 erroneously clears interp->result when new va
      
    11. type initialized to: "Bug"
  2. Ticket change [a7e3aa6a22] (rid 98876) by welch on 2000-10-26 08:23:18:

    1. closedate changed to: "2000-10-26T01:23:18"
    2. closer changed to: "welch"
    3. priority changed to: "2"
    4. resolution changed to: "Fixed"
    5. status changed to: "Closed"