Skip to content
Tcl Source Code History Of Ticket 3392070fffffffffffffffffffffffffffffffff
Login

History Of Ticket 3392070fffffffffffffffffffffffffffffffff

Artifacts Associated With Ticket 3392070fffffffffffffffffffffffffffffffff

  1. Ticket change [586a015996] (rid 117799) by dgp on 2011-08-15 17:19:18:

    1. assignee initialized to: "dgp"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      
      This exercise of the test suite leaks:
      
      $ make valgrind TESTFLAGS='-file "regexpComp.test subst.test" -match "regexpComp-12.1 subst-3.2"'
      ...
      ==4233== 292 (48 direct, 244 indirect) bytes in 1 blocks are definitely lost in loss record 23 of 24
      ==4233==    at 0x4A05E1C: malloc (vg_replace_malloc.c:195)
      ==4233==    by 0x498654: Tcl_Alloc (in /local/tmp/dgp/fossil/tcl-only/unix/tcltest)
      ==4233==    by 0x4FB2CA: TclCreateLiteral (in /local/tmp/dgp/fossil/tcl-only/unix/tcltest)
      ==4233==    by 0x44821F: InitLocalCache (in /local/tmp/dgp/fossil/tcl-only/unix/tcltest)
      ==4233==    by 0x4488F0: TclNRInterpProcCore (in /local/tmp/dgp/fossil/tcl-only/unix/tcltest)
      ==4233==    by 0x48E315: TclNRRunCallbacks (in /local/tmp/dgp/fossil/tcl-only/unix/tcltest)
      ==4233==    by 0x493E03: TclEvalEx (in /local/tmp/dgp/fossil/tcl-only/unix/tcltest)
      ==4233==    by 0x494135: Tcl_EvalEx (in /local/tmp/dgp/fossil/tcl-only/unix/tcltest)
      
      Looking at the tests, I suspect the literal value "j" is leaking,
      but don't have anything more concrete than that yet.
      
    4. foundin initialized to: "obsolete: 8.6b2"
    5. is_private initialized to: "0"
    6. priority initialized to: "5 Medium"
    7. resolution initialized to: "None"
    8. status initialized to: "Open"
    9. submitter initialized to: "dgp"
    10. subsystem initialized to: "47. Bytecode Compiler"
    11. title initialized to: "literal leak in regexpComp/subst combination"
    12. type initialized to: "Bug"
  2. Ticket change [34f3c94807] (rid 106828) by dgp on 2011-08-16 02:39:24:

    1. icomment:
      
      Reduced leak demonstration...
      
      $ cat a.tcl
      source b.tcl
      
      $ cat b.tcl
      proc foo {} {
          regexp . x j
          return $j
      }
      foo
      subst \j
      
      $ valgrind ./tcltest a.tcl
      ...
      ==6105== 292 (48 direct, 244 indirect) bytes in 1 blocks are definitely lost in loss record 23 of 24
      ==6105==    at 0x4A05E1C: malloc (vg_replace_malloc.c:195)
      ==6105==    by 0x498654: Tcl_Alloc (in /local/tmp/dgp/fossil/tcl-only/unix/tcltest)
      ==6105==    by 0x4FB2CA: TclCreateLiteral (in /local/tmp/dgp/fossil/tcl-only/unix/tcltest)
      ==6105==    by 0x4FB501: TclRegisterLiteral (in /local/tmp/dgp/fossil/tcl-only/unix/tcltest)
      ==6105==    by 0x4CF24A: TclCompileTokens (in /local/tmp/dgp/fossil/tcl-only/unix/tcltest)
      ==6105==    by 0x4CE6A6: TclCompileScript (in /local/tmp/dgp/fossil/tcl-only/unix/tcltest)
      ==6105==    by 0x4D0A6B: TclSetByteCodeFromAny (in /local/tmp/dgp/fossil/tcl-only/unix/tcltest)
      ==6105==    by 0x4D0BB6: SetByteCodeFromAny (in /local/tmp/dgp/fossil/tcl-only/unix/tcltest)
      ==6105==    by 0x4E5065: TclCompileObj (in /local/tmp/dgp/fossil/tcl-only/unix/tcltest)
      ==6105==    by 0x494338: TclNREvalObjEx (in /local/tmp/dgp/fossil/tcl-only/unix/tcltest)
      
      
      Debugging prints show the literal "j" is not released by
      TclDeleteLiteralTable() due to a surplus refcount.
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  3. Ticket change [019b8bbd48] (rid 119508) by hobbs on 2011-08-16 02:43:17:

    1. icomment:
      Perhaps the hard-coded compiled regexp cache is never freed?  This is process wide and size limited though, so not a big deal.
      
      
    2. login: "hobbs"
    3. mimetype: "text/plain"
    4. username: "hobbs"
  4. Ticket change [fe74efb539] (rid 108594) by dgp on 2011-08-16 23:04:44:

    1. icomment:
      Simpler, single-file demo that exonerates [regexp]:
      
      if 1 {
        proc foo {} {
          scan x %c j
          return $j
        }
        foo
        set subst subst
        $subst j
      }
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. title changed to: "literal leak with delayed compile [subst]"
    5. username: "dgp"
  5. Ticket change [62217baa29] (rid 92362) by ferrieux on 2011-08-17 00:26:45:

    1. icomment:
      The leaking case seems to be correlated with shimmering from localVarName to substCode:
      
      
      set repr ::tcl::unsupported::representation
      if 1 {
      proc foo {} {
      scan x %c j
      return $j
      }
      foo
      puts [$repr j]
      set subst subst
      $subst j
      puts [$repr j]
      }
      
      =>
      
      
      value is a localVarName with a refcount of 5, object pointer at 0x4237408, internal representation (nil):(nil), string representation "j".
      value is a substcode with a refcount of 6, object pointer at 0x4237408, internal representation 0x423cad8:0x7, string representation "j".
      ==16322==    definitely lost: 24 bytes in 1 blocks
      
      While (shimmering to List in between):
      
      
      set repr ::tcl::unsupported::representation
      if 1 {
      proc foo {} {
      scan x %c j
      return $j
      }
      proc bar x {
      llength $x
      }
      foo
      puts [$repr j]
      bar j
      puts [$repr j]
      
      set subst subst
      $subst j
      puts [$repr j]
      }
      
      =>
      
      
      value is a localVarName with a refcount of 5, object pointer at 0x4237878, internal representation (nil):(nil), string representation "j".
      value is a list with a refcount of 5, object pointer at 0x4237878, internal representation 0x423d848:(nil), string representation "j".
      value is a substcode with a refcount of 5, object pointer at 0x4237878, internal representation 0x423dea0:0x7, string representation "j".
      ==16479==    definitely lost: 0 bytes in 0 blocks
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  6. Ticket change [d50660d676] (rid 123547) by dgp on 2011-08-17 00:44:44:

    1. icomment:
      Lookie what DupLocalVarName does!
      Look familiar?  The copied value keeps
      a reference to the original, so taking a dup
      to stop cycles doesn't get the job done.
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  7. Ticket change [eacfcbce27] (rid 103431) by dgp on 2011-08-17 01:04:28:

    1. icomment:
      
      This is suggesting that the "Dup to avoid a cycle"
      strategy is not sufficient.  If we've got these issues
      in multiple internal Tcl_ObjTypes it's a near certainty
      that some extension Tcl_ObjTypes do as well, and
      we haven't had any explicit docs against the practice,
      have we?
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  8. Ticket change [b25856240f] (rid 98318) by dgp on 2011-08-17 02:13:28:

    1. icomment:
      Confirmed that if I disable the
      "localVarName" type completely,
      the leak goes away while adding
      no failed tests.  No idea what that
      does to performance or other matters
      though.  The type must be there for
      a reason.
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  9. Ticket change [ea5b586dd7] (rid 103362) by dgp on 2011-08-17 02:50:42:

    1. icomment:
      
      Branch bug-3392070 holds a proposed fix.
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  10. Ticket change [2fffee7933] (rid 93170) by msofer on 2011-08-17 04:42:51:

    1. icomment:
      Note that this code should be unchanged from Tcl8.5
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  11. Ticket change [6792faea2c] (rid 102912) by dgp on 2011-08-17 19:40:21:

    1. closedate changed to: "2011-08-17T12:40:21"
    2. closer changed to: "dgp"
    3. icomment:
      
      
      allow_comments - 1
      
      
      
    4. login: "dgp"
    5. mimetype: "text/plain"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"
    8. username: "dgp"