Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 254ed32d79346a67d955266681dcbbf275f8416b
Ticket: 1740631fffffffffffffffffffffffffffffffff
Memory corruption in Tcl_UpdateLinkedVar
User & Date: nobody on 2007-06-20 23:22:43
Changes

  1. assignee changed to: "hobbs"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    Solaris 10 on sparc
    
    Calling Tcl_UnlinkVar in a callback that is invoked by Tcl_UpdateLinkedVar causes memory corruption because linkPtr is used after it has been freed.
    
    Here is a patch to fix the problem by making a second call to Tcl_VarTraceInfo.
    
    --- tcl8.4.15/generic/tclLink.c       2007-05-10 11:23:58.000000000 -0700
    +++ tcl8.4.15-new/generic/tclLink.c   2007-06-20 14:19:24.792783000 -0700
    @@ -206,6 +206,12 @@
         Tcl_IncrRefCount(objPtr);
         Tcl_ObjSetVar2(interp, linkPtr->varName, NULL, objPtr, TCL_GLOBAL_ONLY);
         Tcl_DecrRefCount(objPtr);
    +    /* Callback may have unlinked the variable */
    +    linkPtr = (Link *) Tcl_VarTraceInfo(interp, varName, TCL_GLOBAL_ONLY,
    +           LinkTraceProc, (ClientData) NULL);
    +    if (linkPtr == NULL) {
    +       return;
    +    }
         linkPtr->flags = (linkPtr->flags & ~LINK_BEING_UPDATED) | savedFlag;
     }
    
    
  4. foundin changed to: "obsolete: 8.4.15"
  5. is_private changed to: "0"
  6. priority changed to: "5 Medium"
  7. resolution changed to: "None"
  8. status changed to: "Open"
  9. submitter changed to: "nobody"
  10. subsystem changed to: "09. Linked C Variables"
  11. title changed to: "Memory corruption in Tcl_UpdateLinkedVar"
  12. type changed to: "Bug"