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

History Of Ticket 1334947fffffffffffffffffffffffffffffffff

Artifacts Associated With Ticket 1334947fffffffffffffffffffffffffffffffff

  1. Ticket change [b72e6a29e3] (rid 125538) by msofer on 2005-10-22 15:25:12:

    1. assignee initialized to: "dgp"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      The refCount management of TclPtrSetVar, and also its
      different "front ends" in tclVar.c, presents one
      particular problem which was revealed by [Bug 1191369]
      (both 8.4 and 8.5 are concerned).
      
      The problem arises when the newValuePtr obj has refCount 0:
      
      (1) if setting the new value succeeds as requested,
      newValuePtr gets its refCount incremented to reflect
      the new reference
      
      (2) if setting the new value fails early (eg, trying to
      set an array to a scalar value), newValuePtr's refCount
      is not touched 
      
      (3) If there is a write trace that does not allow the
      value to be set as requested, newValuePtr's refCount
      will be incremented/decremented, resulting in it being
      freed. 
      
      This renders the caller's refCount management rather
      critical, as reflected in 1191369. There are other
      spots in the core where a similar bug is present.
      Example: Tcl_AddObjErrorInfo would leak an obj if
      errorCode or errorInfo redefined to be arrays (I know,
      well deserved); Tcl_Main would leak if "argc" was an
      array. Worse, witness (in a MEM_DEBUG HEAD):
      
      % trace add variable a write {return -code error "RO
      var";#}
      % regexp qw qwerty -> a
      couldn't set variable "a"
      % set a
      file = ../generic/tclExecute.c, line = 2099
      Trying to increment refCount of previously disposed object.
      
      
      There are two possible fixes:
       
      (a) fix all callers so that they incr before calling,
      decr on return. Add a warning in the docs.
      
      (b) fix TclPtrSetVar so that it does incr/decr for all
      paths where it fails to set the value as requested,
      allowing the callers to delegate the refCount
      management to TclPtrSetVar. The callers still have to
      be fixed to not touch that refCount.
      
      I have a preference for (b); assigning to dgp as a
      request for opinion. Please comment and assign back.
      
    4. foundin initialized to: "obsolete: 8.4.11"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "msofer"
    9. subsystem initialized to: "07. Variables"
    10. title initialized to: "refCounts on PtrSetVar failure"
    11. type initialized to: "Bug"
  2. Ticket change [1b77501d2f] (rid 123156) by msofer on 2005-10-22 22:27:50:

    1. priority changed to: "9 Immediate"
  3. Ticket change [903d35b073] (rid 120419) by msofer on 2005-10-22 22:30:09:

    1. icomment:
      Logged In: YES 
      user_id=148712
      
      correction to (b): either not touch it, or else incr/decr on
      all paths.
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  4. Ticket change [104a0b1ab3] (rid 94945) by msofer on 2005-10-22 22:42:13:

    1. icomment:
      Logged In: YES 
      user_id=148712
      
      Better crash example:
      % trace add variable a write {set a 1; return -code error
      "RO var";#}
      % regexp qw qwerty -> a
      file = ../generic/tclCmdMZ.c, line = 370
      Trying to decrement refCount of previously disposed object.
      
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  5. Ticket change [e0764f3bda] (rid 115201) by msofer on 2005-10-23 05:42:37:

    1. icomment:
      Logged In: YES 
      user_id=148712
      
      Clarifying my thoughts: the real "bug" is that some failure
      paths do not clear 0-ref objs, some do not. This makes it
      imperative for callers to manage the refCount explicitly. 
      
      If a new obj is created by the caller and used as new value
      without incrementing its refCount, the handling of error
      returns is impossible to get right:either you DecrRefCount
      and crash on errors caused by traces, or you don't and leak
      the obj on other errors.
      
      My preference for alternative (b) is that it allows the
      fire-and-forget technique: just call e.g. 
        Tcl_ObjSetVar2(interp, part1Ptr, part2Ptr, Tcl_NewObj(),
      flags)
      and forget all about that object's fate in the knowledge
      that it will be disposed of proeprly (as is currently done
      in  error by eg Tcl_AddObjErrorInfo).
      
      Maybe a similar policy would make sense for other
      interfaces, eg Tcl_ListObjAppendElement?
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  6. Ticket change [b337880ade] (rid 98484) by jenglish on 2005-10-23 06:52:11:

    1. icomment:
      Logged In: YES 
      user_id=68433
      
      FWIW, I agree with Miguel that option (b) is strongly
      preferable.  Callers should be able to pass a fresh Tcl_Obj*
      to Tcl_ObjSetVar() and relatives without having to increment
      / decrement the refcount before and after.
      
      
    2. login: "jenglish"
    3. mimetype: "text/plain"
    4. username: "jenglish"
  7. Ticket change [30dde04f34] (rid 93329) by msofer on 2005-10-24 05:05:25:

    1. icomment:
      Logged In: YES 
      user_id=148712
      
      Fixed in 8.4 by method (a). Attempting (b) caused many
      testsuite failures, a fix was deemed too risky as many
      extensions may have copied the buggy core code. Patch
      attached to this ticket.
      
      HEAD still untouched.
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  8. Ticket change [5f572b1f20] (rid 115804) by msofer on 2005-10-24 05:05:26:

    1. icomment:
      
      
      File Added - 153548: 1334947-8-4.patch
      
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  9. Add attachment "1334947-8-4.patch" [6c33aac94d] (rid 128460) by msofer on 2005-10-24 05:05:26.

  10. Ticket change [6fd1f63790] (rid 100375) by msofer on 2005-10-24 07:46:21:

    1. foundin changed to: "obsolete: 8.5a4"
  11. Ticket change [cfd439fb2e] (rid 113056) by dgp on 2005-11-01 21:30:07:

    1. assignee changed to: "msofer"
  12. Ticket change [291974deae] (rid 88814) by msofer on 2005-11-05 05:42:49:

    1. closedate changed to: "2005-11-04T22:42:49"
    2. closer changed to: "msofer"
    3. icomment:
      Logged In: YES 
      user_id=148712
      
      Fixed in HEAD by method (b).
      
      
    4. login: "msofer"
    5. mimetype: "text/plain"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"
    8. username: "msofer"
  13. Add attachment "1334947-8-5.patch" [3580bfd106] (rid 106948) by msofer on 2005-11-05 05:42:49.

  14. Ticket change [65a74c9121] (rid 102588) by msofer on 2005-11-05 05:42:50:

    1. icomment:
      
      
      File Added - 155064: 1334947-8-5.patch
      
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  15. Ticket change [5648a1eaf3] (rid 94290) by dgp on 2013-03-08 22:51:22:

    1. icomment:
      
      This bug fix causes segfaults in Tk.
      See Tk Bug 3607326.
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  16. Ticket change [78cea2fb05] (rid 90025) by dgp on 2013-03-08 22:51:23:

    1. resolution changed to: "None"
    2. status changed to: "Open"
  17. Ticket change [3980cc9508] (rid 112402) by dgp on 2013-03-12 00:03:42:

    1. icomment:
      
      This patch changed the refcount demands of
      several variable setting routines.  The new
      interface contract is much nicer, but some existing
      code was written to the old requirements, and
      hasn't yet been updated to the new reality.  This
      code now breaks in ugly ways.
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  18. Ticket change [55a5c34c6f] (rid 94178) by dgp on 2013-03-12 00:37:27:

    1. icomment:
      Calling TclFreeObj() on the same value
      twice causes really severe damage.  At
      least in TCL_MEM_DEBUG mode we 
      should better detect and report this.  This
      will help a great deal finding the next bug
      of this same kind, if any remain.
      
      Patch committed to 8.5 branch.
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  19. Ticket change [7eff6bbc7e] (rid 97500) by dgp on 2013-03-12 00:40:37:

    1. closedate changed to: "2013-03-11T17:40:37"
    2. closer changed to: "dgp"
    3. icomment:
      
      
      allow_comments - 1
      
      ...and trunk.
      
      
    4. login: "dgp"
    5. mimetype: "text/plain"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"
    8. username: "dgp"