Skip to content
Tcl Source Code History Of Ticket 217792
Login

History Of Ticket 217792

Artifacts Associated With Ticket 217792

  1. Ticket change [0d822c3801] (rid 114375) by nobody on 2000-10-26 00:43:43:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      OriginalBugID: 917 Bug
      Version: 8.0.3
      SubmitDate: '1998-12-04'
      LastModified: '1998-12-16'
      Severity: SER
      Status: Closed
      Submitter: welch
      ChangedBy: pat
      OS: Windows NT
      Machine: X86
      FixedDate: '2000-10-25'
      ClosedDate: '1998-12-16'
      
      
      Name:
      Matt Newman
      
      CVS:
      updated today (11/13/98) tcl8.0/generic/tclTimer.c $Id: tclTimer.c,v 1.2 1998/09/14 18:40:02 stanton Exp $
      
      Extensions:
      BLT2.4f, Incr Tcl 3.01, DP 4.0b2, TclODBC2.0 and many many more
      
      CustomShell:
      My version of the core is a virgin 8.0.3 plus local bug fixes. This submission is the first of a handful that I need to submit (when I have the time).
      
      ReproducibleScript:
      tclsh80
      
      after 1000 [list set aVar "abc\0def"]
      after 1000
      update
      if {[string compare $aVar "abc\0def"]!=0} {
         tclLog "BUG!"
      }
      
      ObservedBehavior:
      The issue is that the after command support in tclTimer.c does not use the TclObj support and therefore all data with embedded nulls gets discarded.
      
      DesiredBehavior:
      Use the TclObj interface so all data is preserved.
      
      Patch:
      *** tclTimer.c.oldFri Nov 13 15:04:41 1998
      --- tclTimer.c.newMon Oct 26 17:12:24 1998
      ***************
      *** 9,15 ****
         * See the file \"license.terms\" for information on usage and redistribution
         * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
         *
      !  * RCS: @(#) \$Id: tclTimer.c,v 1.2 1998/09/14 18:40:02 stanton Exp \$
         */
      
        #include \"tclInt.h\"
      --- 9,15 ----
         * See the file \"license.terms\" for information on usage and redistribution
         * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
         *
      !  * SCCS: @(#) tclTimer.c 1.9 97/07/29 16:21:53
         */
      
        #include \"tclInt.h\"
      ***************
      *** 54,60 ****
        /* Pointer to the \"tclAfter\" assocData for
         * the interp in which command will be
         * executed. */
      ! \!
          char *command\;/* Command to execute.  Malloc'ed, so must
         * be freed when structure is deallocated. */
            int id\;/* Integer identifier for command\;  used to
         * cancel it. */
      --- 54,60 ----
        /* Pointer to the \"tclAfter\" assocData for
         * the interp in which command will be
         * executed. */
      !     Tcl_Obj *command\;/* Command to execute.  Malloc'ed, so must
         * be freed when structure is deallocated. */
            int id\;/* Integer identifier for command\;  used to
         * cancel it. */
      ***************
      *** 221,226 ****
      --- 221,230 ----
             * Compute when the event should fire.
             */
      
      +     if (milliseconds == 0) \{/* Optimize for zero-wait timer events */
      + timerHandlerPtr->tim!
      e.sec = 0\;
      + timerHandlerPtr->time.usec = 0\;
      +     \} else \{
            TclpGetTime(&time)\;
            timerHandlerPtr->time.sec = time.sec + milliseconds/1000\;
            timerHandlerPtr->time.usec = time.usec + (milliseconds%1000)*1000\;
      ***************
      *** 228,233 ****
      --- 232,238 ----
        timerHandlerPtr->time.usec -= 1000000\;
        timerHandlerPtr->time.sec += 1\;
            \}
      + \}
      
            /*
             * Fill in other fields for the event.
      ***************
      *** 342,348 ****
        /*
         * Compute the timeout for the next timer on the list.
         */
      ! 
        TclpGetTime(&blockTime)\;
        blockTime.sec = firstTimerHandlerPtr->time.sec - blockTime.sec\;
        blockTime.usec = firstTimerHandlerPtr->time.usec - blockTime.usec\;
      --- 347,358 ----
        /*
         * Compute the timeout for the\!
       next timer on the list.
         */
      !     if (firstTimerHandlerPtr->time.sec == 0 &&
      ! firstTimerHandlerPtr->time.sec == 0) \{/* Optimize for zero-wait timer events */
      ! blockTime.sec = 0\;
      ! blockTime.usec = 0\;
      !     Tcl_SetMaxBlockTime(&blockTime)\;
      !     \}
        TclpGetTime(&blockTime)\;
        blockTime.sec = firstTimerHandlerPtr->time.sec - blockTime.sec\;
        blockTime.usec = firstTimerHandlerPtr->time.usec - blockTime.usec\;
      ***************
      *** 737,742 ****
      --- 747,753 ----
            static char *subCmds\[\] = \{
                \"cancel\", \"idle\", \"info\",
                (char *) NULL\}\;
      +     Tcl_Obj*resultObj\;
      
            if (objc < 2) \{
        Tcl_WrongNumArgs(interp, 1, objv, \"option ?arg arg ...?\")\;
      ***************
      *** 785,800 ****
        afterPtr = (AfterInfo *) ckalloc((unsi!
      gned) (sizeof(AfterInfo)))\;
        afterPtr->assocPtr = assocPtr\;
        if (objc == 3) \{
      !     arg = Tcl_GetStringFromObj(objv\[2\], &length)\;
      !     afterPtr->command = (char *) ckalloc((unsigned) (length + 1))\;
      !     strcpy(afterPtr->command, arg)\;
        \} else \{
      !     Tcl_Obj *objPtr = Tcl_ConcatObj(objc-2, objv+2)\;
      !     arg = Tcl_GetStringFromObj(objPtr, &length)\;
      !     afterPtr->command = (char *) ckalloc((unsigned) (length + 1))\;
      !     strcpy(afterPtr->command, arg)\;
      !     Tcl_DecrRefCount(objPtr)\;
        \}
        afterPtr->id = nextId\;
        nextId += 1\;
        afterPtr->token = Tcl_CreateTimerHandler(ms, AfterProc,
      --- 796,806 ----
        afterPtr = (AfterInfo *) ckalloc((unsigned) (sizeof(AfterInfo)))\;
        afterPtr->assocPtr = assocPtr\;
        if (objc == 3) \{
      !     afterPtr->co!
      mmand = Tcl_DuplicateObj( objv\[2\])\;
        \} else \{
      !     afterPtr->command = Tcl_ConcatObj(objc-2, objv+2)\;
        \}
      + Tcl_IncrRefCount( afterPtr->command)\;
        afterPtr->id = nextId\;
        nextId += 1\;
        afterPtr->token = Tcl_CreateTimerHandler(ms, AfterProc,
      ***************
      *** 821,826 ****
      --- 827,834 ----
                case 0:/* cancel */
            \{
        char *arg\;
      + char *string2\;
      + intlength2, length3, match\;
        Tcl_Obj *objPtr = NULL\;
      
        if (objc < 3) \{
      ***************
      *** 835,841 ****
        \}
        for (afterPtr = assocPtr->firstAfterPtr\; afterPtr != NULL\;
             afterPtr = afterPtr->nextPtr) \{
      !     if (strcmp(afterPtr->command, arg) == 0) \{
        break\;
            \}
        \}
      --- 843,855 ----
        \}
        f!
      or (afterPtr = assocPtr->firstAfterPtr\; afterPtr != NULL\;
             afterPtr = afterPtr->nextPtr) \{
      ! string2 = Tcl_GetStringFromObj(afterPtr->command, &length2)\;
      ! length3 = (length < length2) ? length : length2\;
      ! match = memcmp(arg, string2, (unsigned) length3)\;
      ! if (match == 0) \{
      ! match = length - length2\;
      ! \}
      !     if (match == 0) \{
        break\;
            \}
        \}
      ***************
      *** 863,878 ****
            afterPtr = (AfterInfo *) ckalloc((unsigned) (sizeof(AfterInfo)))\;
            afterPtr->assocPtr = assocPtr\;
            if (objc == 3) \{
      ! arg = Tcl_GetStringFromObj(objv\[2\], &length)\;
      ! afterPtr->command = (char *) ckalloc((unsigned) length + 1)\;
      ! strcpy(afterPtr->command, arg)\;
            \} else \{
      ! Tcl_Obj *objPt!
      r = Tcl_ConcatObj(objc-2, objv+2)\;\;
      ! arg = Tcl_GetStringFromObj(objPtr, &length)\;
      ! afterPtr->command = (char *) ckalloc((unsigned) (length + 1))\;
      ! strcpy(afterPtr->command, arg)\;
      ! Tcl_DecrRefCount(objPtr)\;
            \}
            afterPtr->id = nextId\;
            nextId += 1\;
            afterPtr->token = NULL\;
      --- 877,887 ----
            afterPtr = (AfterInfo *) ckalloc((unsigned) (sizeof(AfterInfo)))\;
            afterPtr->assocPtr = assocPtr\;
            if (objc == 3) \{
      ! afterPtr->command = Tcl_DuplicateObj(objv\[2\])\;
            \} else \{
      ! afterPtr->command = Tcl_ConcatObj(objc-2, objv+2)\;\;
            \}
      + Tcl_IncrRefCount( afterPtr->command)\;
            afterPtr->id = nextId\;
            nextId += 1\;
            afterPtr->token = NULL\;
      ***************
      *** 905,913 ***!
      *
        \"\\\" doesn't exist\", (char *) NULL)\;
        return TCL_ERROR\;
            \}
      !     Tcl_AppendElement(interp, afterPtr->command)\;
      !     Tcl_AppendElement(interp,
      !     (afterPtr->token == NULL) ? \"idle\" : \"timer\")\;
            break\;
            \}
            return TCL_OK\;
      --- 914,924 ----
        \"\\\" doesn't exist\", (char *) NULL)\;
        return TCL_ERROR\;
            \}
      ! resultObj = Tcl_GetObjResult(interp)\;
      ! Tcl_ListObjAppendElement( interp, resultObj, afterPtr->command)\;
      ! Tcl_ListObjAppendElement( interp, resultObj,
      ! Tcl_NewStringObj( (afterPtr->token == NULL) ? \"idle\" : \"timer\", -1))\;
      ! Tcl_SetObjResult( interp, resultObj)\;
            break\;
            \}
            return TCL_OK\;
      ***************
      *** 1012,1018 ****
      
            interp = assoc!
      Ptr->interp\;
            Tcl_Preserve((ClientData) interp)\;
      !     result = Tcl_GlobalEval(interp, afterPtr->command)\;
            if (result != TCL_OK) \{
        Tcl_AddErrorInfo(interp, \"\\n    (\\\"after\\\" script)\")\;
        Tcl_BackgroundError(interp)\;
      --- 1023,1029 ----
      
            interp = assocPtr->interp\;
            Tcl_Preserve((ClientData) interp)\;
      !     result = Tcl_GlobalEvalObj(interp, afterPtr->command)\;
            if (result != TCL_OK) \{
        Tcl_AddErrorInfo(interp, \"\\n    (\\\"after\\\" script)\")\;
        Tcl_BackgroundError(interp)\;
      ***************
      *** 1023,1029 ****
             * Free the memory for the callback.
             */
      
      !     ckfree(afterPtr->command)\;
            ckfree((char *) afterPtr)\;
        \}
        \f
      --- 1034,1040 ----
             * Free the memory for the callback.
           !
        */
      
      !     Tcl_DecrRefCount(afterPtr->command)\;
            ckfree((char *) afterPtr)\;
        \}
        \f
      ***************
      *** 1062,1068 ****
        \}
        prevPtr->nextPtr = afterPtr->nextPtr\;
            \}
      !     ckfree(afterPtr->command)\;
            ckfree((char *) afterPtr)\;
        \}
        \f
      --- 1073,1079 ----
        \}
        prevPtr->nextPtr = afterPtr->nextPtr\;
            \}
      !     Tcl_DecrRefCount(afterPtr->command)\;
            ckfree((char *) afterPtr)\;
        \}
        \f
      ***************
      *** 1101,1107 ****
        \} else \{
            Tcl_CancelIdleCall(AfterProc, (ClientData) afterPtr)\;
        \}
      ! ckfree(afterPtr->command)\;
        ckfree((char *) afterPtr)\;
            \}
            ckfree((char *) assocPtr)\;
      --- 1112,1118 ----
        \} else \{
            Tcl_CancelIdleCall(AfterProc, (ClientData) afterPtr)\;!
      
        \}
      ! Tcl_DecrRefCount(afterPtr->command)\;
        ckfree((char *) afterPtr)\;
            \}
            ckfree((char *) assocPtr)\;
      
      PatchFiles:
      tcl8.0/generic/tclTimer.c
      
      
      
      Please note I have been shipping a commerial system based upon this critical patch since the begining of the year, and currently this is the primary reason I can't use the TclPro versions of the tcl runtime dlls.
      
      Duplicate of bug 848 (12/16/98 pat)
      
      
      
    4. foundin initialized to: "obsolete: 8.0.3"
    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:
      tclTimer.c (i.e. after command) does not use TclObj interfac
      
    11. type initialized to: "Bug"
  2. Ticket change [c1bd020217] (rid 111373) by welch on 2000-10-26 07:49:18:

    1. closedate changed to: "2000-10-26T00:49:18"
    2. closer changed to: "welch"
    3. priority changed to: "1 Zero"
    4. resolution changed to: "Duplicate"
    5. status changed to: "Closed"
  3. Ticket change [c4f6483ddb] (rid 111915) by dgp on 2001-04-13 22:52:05:

    1. closedate changed to: "2001-04-13T15:52:05"
    2. closer changed to: "dgp"
    3. subsystem changed to: "03. Timer Events"