Skip to content
Tcl Source Code History Of Ticket 219397ffffffffff
Login

History Of Ticket 219397ffffffffff

Artifacts Associated With Ticket 219397ffffffffff

  1. Ticket change [a766c581be] (rid 98786) by nobody on 2000-10-26 05:12:24:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      OriginalBugID: 6226 Bug
      Version: 8.3.2
      SubmitDate: '2000-09-07'
      LastModified: '2000-09-08'
      Severity: MED
      Status: UnAssn
      Submitter: techsupp
      ChangedBy: ericm
      OS: Solaris
      OSVersion: 5.7
      Machine: sun4u sparc SUNW,Ultra-5_10
      FixedDate: '2000-10-25'
      ClosedDate: '2000-10-25'
      
      
      Name:
      Fabrice Pardo
      
      ReproducibleScript:
      1) add lines to tclTest.c (see below)
      2) change MEM_DEBUG_FLAGS option in Makefile to -DTCL_MEM_DEBUG
      3) do a "make clean; make runtest"
      
          % history keep 0
          % tolist {x  y} 1 ; memory info ;# repeat, "current packets allocated" is growing
          % tolist {x y} 1  ; memory info ;# repeat, "current packets allocated" is not growing
      
      ########################
      lines added to tclTest.c
      ########################
      
      ...
      static intTesttolistObjCmd _ANSI_ARGS_((ClientData dummy,
          Tcl_Interp *interp, int objc,
          Tcl_Obj *CONST objv[]));
      ...
      
      /*----------------------------------------------------------------------
       *
       * TesttolistObjCmd --
       *
       *      This function implements a "tolist _list_ _invalStringFlag_"
       *      command, similar to
       *      "lrange _list_ 0 end" command when _invalStringFlag_ == 0,
       *      with an added call to Tcl_InvalidateStringRep(_list_)
       *      when _invalStringFlag_ == 1
       *
       * Results:
       *      The _list_ argument
       *
       * Side effects:
       *      # take care on 1 or 2 spaces between x and y.
       *      tolist {x  y} 1 ;# undesireable memory grown in interactive mode
       *      tolist {x y} 1  ;# no side effect
       *      tolist {x  t} 0 ;# no side effect
       *      set l {x  y}
       *      tolist $x 1     ;# no side effect
       */
      
      int
      TesttolistObjCmd(notUsed, interp, objc, objv)
          ClientData notUsed;/* Not used. */
          Tcl_Interp *interp;/* Current interpreter. */
          int objc;/* Number of arguments. */
          register Tcl_Obj *CONST objv[];/* Argument objects. */
      {
          Tcl_Obj *listPtr;
          Tcl_Obj **elemPtrs;
          int listLen, invalStringFlag, result;
      
          if (objc != 3) {
      Tcl_WrongNumArgs(interp, 1, objv, "list invalStringFlag");
      return TCL_ERROR;
          }
      
          listPtr = objv[1];
          result = Tcl_ListObjGetElements(interp, listPtr, &listLen, &elemPtrs);
          if (result != TCL_OK) {
      return result;
          }
      
          if (Tcl_GetBooleanFromObj(interp, objv[2], &invalStringFlag) != TCL_OK) {
              return TCL_ERROR;
          }
      
          if (invalStringFlag) {
              Tcl_InvalidateStringRep(listPtr);
          }
      
          Tcl_SetListObj(Tcl_GetObjResult(interp), listLen, elemPtrs);
          return TCL_OK;
      }
      
      ...
          Tcl_CreateObjCommand(interp, "tolist", TesttolistObjCmd, 0, NULL);
      ...
      
      ObservedBehavior:
      If an argument is converted to a list
      and if his internal string representation
      is invalidated, there is a memory
      leak if the internal string representation
      was not canonical (e.g. "x  y" instead of "x y").
      
      This is because TclReleaseLiteral procedure
      doesnt find the new string internal representation
      "x y" in his database.
      
      Is it a compiler bug, or an Object/Tcl_InvalidateStringRep
      insufficient documentation ?
      
      
      
      Comment from Paul Duffin (via comp.lang.tcl):
      
      There is no memory leak because the string is still reachable from the
      literal table. However, there may be a problem if the literal table
      can grow forever but it won't be a memory leak.
      e.g. if the following code could potentially add a thousand strings
      to the literal table (not sure if it does) which is 'leaked' as
      far as the application is concerned.
      
              set string a
              for {set i 0} {$i < 1000} {incr i} {
                  eval puts $string
                  append string a
              }
       
      -- 09/08/2000 ericm
      
    4. foundin initialized to: "obsolete: 8.3.2"
    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: "69. Other"
    10. title initialized to: "Memory leak after Tcl_InvalidateStringRep"
    11. type initialized to: "Bug"
  2. Ticket change [7b55c16666] (rid 90500) by dkf on 2000-11-20 18:33:15:

    1. icomment:
      I suspect that for this bug to bite in an application, the contortions you'd be going through to achieve it would be pretty horrible.  Normal code (particularly stuff inside some finite number of procedures, which describes most stuff written) is not going to be hit by this.
      
      It is quite possible that Tcl_Main ought to be passing the TCL_EVAL_DIRECT flag to Tcl_RecordAndEval and that this would in fact fix the problem by inhibiting compilation of code typed in interactively.  But I'm not sure that this would be the right thing to do...
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. subsystem changed to: "15. Dict Object"
    5. username: "dkf"
  3. Ticket change [bc769b3133] (rid 101755) by dkf on 2001-02-08 21:33:50:

    1. subsystem changed to: "10. Objects"
  4. Ticket change [b419bbad44] (rid 124966) by hobbs on 2001-08-02 08:41:06:

    1. assignee changed to: "hobbs"
  5. Ticket change [01a6552d37] (rid 119514) by hobbs on 2001-08-07 05:29:12:

    1. closedate changed to: "2001-08-06T22:29:12"
    2. closer changed to: "hobbs"
    3. icomment:
      Logged In: YES 
      user_id=72656
      
      This doesn't really seem to be a valid problem unless a 
      regular use case can show that it is.
      
      
    4. login: "hobbs"
    5. mimetype: "text/plain"
    6. resolution changed to: "Wont Fix"
    7. status changed to: "Closed"
    8. username: "hobbs"