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

History Of Ticket 467523ffffffffff

Artifacts Associated With Ticket 467523ffffffffff

  1. Ticket change [9ca7facb0a] (rid 96182) by rbrunner on 2001-10-03 15:47:27:

    1. assignee initialized to: "msofer"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      The following code leaks (in every Tcl version):
      
        interp create foo 
        foo eval {
            namespace eval bar {}
        }
        interp delete foo
      
      Note: 
      
        interp create foo 
        foo eval {
            namespace eval bar {\#}
        }
        interp delete foo
      
      does NOT leak.
      
      Unfortunately I didn't really track down the problem, 
      but the call 
      
        result = Tcl_EvalObjEx(interp, objv[3], 0);
      
      in generic/tclNamesp.c line 2955 (tcl8.4.a3), which is 
      called with an empty string in objv[3] seems to cause 
      the leak. Changing this code to 
      
        if (strlen(Tcl_GetString(objv[3])))
          result = Tcl_EvalObjEx(interp, objv[3], 0);
        else
          result = TCL_OK;
      
      fixes the symptoms, but certainly not the problem.
      (Sorry for not having a proper fix.)
      
    4. foundin initialized to: "obsolete: 8.4a3"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "rbrunner"
    9. subsystem initialized to: "21. [namespace]"
    10. title initialized to: "memory leak in [namespace eval foo {}]"
    11. type initialized to: "Bug"
  2. Ticket change [b4352300a4] (rid 124985) by hobbs on 2001-10-03 23:43:49:

    1. icomment:
      Logged In: YES 
      user_id=72656
      
      Confirmed in 8.3.3.
      
      
    2. login: "hobbs"
    3. mimetype: "text/plain"
    4. priority changed to: "7 High"
    5. username: "hobbs"
  3. Ticket change [578b7d1670] (rid 94500) by msofer on 2001-10-04 00:16:55:

    1. icomment:
      Logged In: YES 
      user_id=148712
      
      I think the leak should occur at any evaluation of {}, ie,
      also for
          proc a {} {}
          a
      
      As I see it, the special handling of "bytecodes with empty
      source" in Tcl_EvalObjEx is at fault. I enclose a small
      patch that should correct this.
      
      Ronnie, Jeff: does this fix the bug?
        
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  4. Ticket change [c3eb1817d0] (rid 111756) by msofer on 2001-10-04 00:16:57:

    1. icomment:
      
      
      File Added - 11528: 467523.patch
      
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  5. Ticket change [77832976e8] (rid 89785) by msofer on 2001-10-04 02:12:50:

    1. icomment:
      Logged In: YES 
      user_id=148712
      
      No, that wasn't it ...
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  6. Ticket change [53627a9298] (rid 93752) by rbrunner on 2001-10-05 02:27:06:

    1. icomment:
      Logged In: YES 
      user_id=205230
      
      Some further observations:
      Any recursive call to Tcl_EvalObjEx with an empty string 
      object to eval leaks:
      
        time {time {}}
        time {switch 1 1 {}}
        switch 1 1 {time {}}
      
      In addition I found out, that these calls leak, whenever 
      the innermost empty code matches the Literal that is added 
      in TclCompile.c line 1041 (tcl8.4a3):
      
        TclRegisterLiteral(envPtr, "", 0, /*onHeap*/ 0)
      
      Setting this to
      
        TclRegisterLiteral(envPtr, "  ", 2, /*onHeap*/ 0)
      
      makes 
      
        time {time {  }}
      
      leak. It seems that this equality increments the empty 
      codes object's refCount (objPtr in Tcl_evalObjEx) to be too 
      high -> it is not cleaned up properly.
      
      
      
    2. login: "rbrunner"
    3. mimetype: "text/plain"
    4. username: "rbrunner"
  7. Ticket change [139a71d4b2] (rid 124253) by msofer on 2001-10-05 20:37:05:

    1. icomment:
      Logged In: YES 
      user_id=148712
      
      The problem (I think) is that the object referred to by the
      literal "" in the slave interp is never freed, as it is
      self-referential: the bytecode pushes itself on the stack,
      so that the bytecode object always has refCount >=1 - it
      appears in its own local literal table. 
      
      The code leaks 164 bytes: 24 for the object, 128 for its
      internal rep as a bytecode, 12 for the handle to the
      interpreter (it would be freed by CleanupByteCode when the
      object is freed).
      
      One possible solution I am exploring is to be more careful
      about sharing literals. The solution to this bug along this
      path could conceivably also fix [Bug 458361] in a roundabout
      way.
      
      
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. subsystem changed to: "47. Bytecode Compiler"
    5. username: "msofer"
  8. Ticket change [673078b502] (rid 102860) by msofer on 2001-10-06 07:02:03:

    1. icomment:
      
      
      File Added - 11620: leak.patch
      
      Logged In: YES 
      user_id=148712
      
      The attached leak.patch to generic/tclLiteral.c
      (TclReleaseLiteral) solves the issue.
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  9. Ticket change [b0c128ca24] (rid 98031) by msofer on 2001-10-06 08:05:05:

    1. closedate changed to: "2001-10-06T01:05:05"
    2. closer changed to: "msofer"
    3. icomment:
      Logged In: YES 
      user_id=148712
      
      Patch committed to HEAD and core-8-3-1-branch
      
      
    4. login: "msofer"
    5. mimetype: "text/plain"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"
    8. username: "msofer"
  10. Ticket change [57a0d3f6fe] (rid 117649) by rbrunner on 2001-10-09 22:39:42:

    1. closedate changed to: "2001-10-09T15:39:42"
    2. closer changed to: "rbrunner"
    3. icomment:
      Logged In: YES 
      user_id=205230
      
      Miguel: did you only patch tclLiteral.c? Compiling with the 
      latest version of this file (1.9, same as 1.8.2.1) tcl8.4a3 
      crashes running the following code:
      
      for {set a 0} {$a < 10} {incr a} {
          namespace eval bar {}
          namespace delete bar
      }
      
      my tclsh dumps core with
      
        file = ./../generic/tclExecute.c, line = 663
        Trying to increment refCount of previously disposed 
      object.
        Abort (core dumped)
      
      
      
    4. login: "rbrunner"
    5. mimetype: "text/plain"
    6. username: "rbrunner"
  11. Ticket change [f039c5dedd] (rid 109150) by msofer on 2001-10-09 23:02:53:

    1. icomment:
      Logged In: YES 
      user_id=148712
      
      Ronnie: Yes, the patch only adds one loc to tclLiteral.c
      
      I do not see any problems with that code in either 8.4a3,
      8.4a4 or the 8-3-1-branch code - your script does not
      trigger a dump on my setup.
      
      Could you help me reproduce the dump? I'd need to know 
        - configure and compile flags
        - how you are running the script: tclsh? tkcon? from a
      file?
        - anything else?
      
      Thanks
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. priority changed to: "8"
    5. status changed to: "Open"
    6. username: "msofer"
  12. Ticket change [fa0602ecd5] (rid 91803) by rbrunner on 2001-10-09 23:38:20:

    1. icomment:
      Logged In: YES 
      user_id=205230
      
      Here a complete log of what I'm doing. Note: running the 
      code in an interactive tclsh works (no dump) and not 
      changing the MEM_DEBUG_FLAGS in Makefile *ALSO* works (no 
      dump). Let me know whether you need the tclConfig.sh or any 
      other additional info ...
      
      > uname -a
      SunOS mlt 5.6 Generic_105181-26 sun4u sparc SUNW,Ultra-250
      > tar xzf tcl8.4a3.tar.gz
      > cd tcl8.4a3/generic
      >
      
      # apply patch to tclLiteral.c (just copy 1.9 over 1.8)
      
      > cd ../unix
      ./configure
      >
      
      # change Makefile to memory debug
          #MEM_DEBUG_FLAGS =
          MEM_DEBUG_FLAGS = -DTCL_MEM_DEBUG
      
      > make
      > setenv LD_LIBRARY_PATH .
      >
      
      # write a mini script foo: vi foo
          #!./tclsh
          for {set a 0} {$a < 10} {incr a} {
      namespace eval bar {}
      namespace delete bar
          }
      
      > chmod +x foo
      > ./foo
      file = ./../generic/tclExecute.c, line = 663
      Trying to increment refCount of previously disposed object.
      Abort (core dumped)
      >
      
      
      
    2. login: "rbrunner"
    3. mimetype: "text/plain"
    4. username: "rbrunner"
  13. Ticket change [b74ae19a25] (rid 125563) by msofer on 2001-10-10 00:03:01:

    1. icomment:
      Logged In: YES 
      user_id=148712
      
      Dump confirmed on linux; I am removing the patch from HEAD
      and core-8-3-1-branch
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  14. Ticket change [f962350dc1] (rid 91698) by msofer on 2001-10-11 20:13:14:

    1. icomment:
      Logged In: YES 
      user_id=148712
      
      I do think I have a correct patch now - the special handling
      of self-referencing bytecodes in TclreleaseLiteral
      (tclLiteral.c) was being done too early (entryPtr->refCount
      == 2 at function entry) and removing two global table
      references in one go (setting entryPtr->refCount to 0) while
      decreasing the object's corresponding refCount by just one.
      
      My earlier patch corrected this by removing a reference to
      the object too - as Ronnie discovered, in some situations
      this caused the object to be accessed after it was removed.
      
      This patch restores "normal handling": each call to
      TclReleaseLiteral removes at most one reference in the
      global table, and the special code for self-referencing
      bytecodes is only used at the last pass.
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  15. Add attachment "leak.patch" [7de57e41d1] (rid 97307) by msofer on 2001-10-11 20:13:14.

  16. Ticket change [668adb0b03] (rid 102729) by msofer on 2001-10-11 20:13:15:

    1. icomment:
      
      
      File Deleted - 11528: 
      
      
      
      File Added - 11851: leak.patch
      
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  17. Ticket change [26938966fa] (rid 88367) by msofer on 2001-10-12 05:37:17:

    1. closedate changed to: "2001-10-11T22:37:17"
    2. closer changed to: "msofer"
    3. icomment:
      Logged In: YES 
      user_id=148712
      
      Patch committed to HEAD and core-8-3-1-branch
      
      
    4. login: "msofer"
    5. mimetype: "text/plain"
    6. status changed to: "Closed"
    7. username: "msofer"
  18. Add attachment "leak.tests" [ee873120b7] (rid 104096) by msofer on 2001-10-12 23:15:28.

  19. Ticket change [88f5445418] (rid 131947) by msofer on 2001-10-12 23:15:28:

    1. closedate changed to: "2001-10-12T16:15:28"
    2. closer changed to: "msofer"
    3. icomment:
      Logged In: YES 
      user_id=148712
      
      Added tests in tests/compile.test - they are only effective
      if tcl was compiled with TCL_MEM_DEBUG
      
      
    4. login: "msofer"
    5. mimetype: "text/plain"
    6. username: "msofer"
  20. Ticket change [bf59bce541] (rid 102237) by msofer on 2001-10-12 23:15:29:

    1. icomment:
      
      
      File Added - 11886: leak.tests
      
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  21. Ticket change [d87cf33cda] (rid 107445) by msofer on 2004-07-16 00:42:21:

    1. icomment:
      Logged In: YES 
      user_id=148712
      
      This bug reappeared with the (faulty) fix of bug #983660 (in
      tcl8.5a2), and was fixed using a different strategy.
      
      The previous strategy was to have special code in
      TclReleaseLiteral to handle the self-references generated by
      empty scripts. The new approach avoids the self-reference
      altogether, by having empty scripts return an unshared literal.
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"