Skip to content
Tcl Source Code History Of Ticket 219113
Login

History Of Ticket 219113

Artifacts Associated With Ticket 219113

  1. Ticket change [bb33c9e14c] (rid 129439) by nobody on 2000-10-26 01:10:59:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      OriginalBugID: 6049 Bug
      Version: 8.3
      SubmitDate: '2000-07-25'
      LastModified: '2000-07-25'
      Severity: MED
      Status: Released
      Submitter: techsupp
      ChangedBy: ericm
      OS: All
      FixedDate: '2000-07-25'
      FixedInVersion: 8.4a2
      ClosedDate: '2000-10-25'
      
      
      Name:
      Stefan Vogel
      
      Extensions:
      None
      
      CustomShell:
      None
      
      ReproducibleScript:
      I've created a trace-callback-function "VariableProc" and registered a trace
      on an array with Tcl_TraceVar2.
      Than the callback is invoked with a call to e.g. "array names ...".
      In the callback-function the array-variable is assigned a new value.
      This causes another Write-Trace.
      
      Here is some code (for Windows?):
      
      #include <tcl.h>
      
      static char*
      VariableProc(clientData, interp, part1, part2, flags)
       ClientData clientData;
       Tcl_Interp* interp;
       char *part1, *part2;
       int flags;
      {
        if (flags & TCL_TRACE_WRITES) {
      printf("--Traced write on %s(%s)\n", part1, part2);
        } else if (flags & TCL_TRACE_ARRAY) {
      printf("--Traced array on array %s(%s)\n Now setting tstkey = tstvalue.\n This will incorrectly call VariableProc with TCL_TRACE_WRITES\n", part1, part2);
      /* Tcl_GetVar2 behaves correctly */
      Tcl_SetVar2(interp, part1, "tstkey", "tstvalue", 0);
      printf("tstkey is set to tstvalue\n");
        }
        return NULL;
      }
      
      __declspec(dllexport) int Array_test_Init(interp)
       Tcl_Interp* interp;
      {
        if (Tcl_InitStubs(interp, "8.3", 0) == NULL) {
      return TCL_ERROR;
        }
        Tcl_PkgProvide(interp, "Array_test", "0.1");
      
        /* Set an initial value to array 'foobar' */
        Tcl_SetVar2(interp, "foobar", "hello", "one", TCL_LEAVE_ERR_MSG);
        /* Put the trace on 'foobar' */
        Tcl_TraceVar2(interp, "foobar", (char*)NULL, 
      (TCL_TRACE_WRITES | TCL_TRACE_READS | TCL_TRACE_UNSETS | TCL_TRACE_ARRAY),
      VariableProc, NULL);
        /* Now executing a TCL_TRACE_ARRAY-trace */
        Tcl_Eval(interp, "array names foobar");
      
        return TCL_OK;
      }
      
      Build a DLL and call your tcl-shell, then call:
      % load array_test.dll
      
      ObservedBehavior:
      The output of the above command "load array_test.dll" is:
      
      Executing: 'array names foobar'
      --Traced array on array foobar((null))
      Now setting tstkey = tstvalue.
      This will incorrectly call VariableProc with TCL_TRACE_WRITES
      --Traced write on foobar(tstkey)
      tstkey is set to tstvalue
      tstkey hello
      %
      
      The Write-trace should not be executed according to the man-page
      
      DesiredBehavior:
      Expected this (from the man-page for Tcl_TraceVar2):
      
      During read, write, and array traces, the trace procedure can read, write, or unset the traced variable using Tcl_GetVar2, Tcl_SetVar2, and other procedures. While proc is executing, traces are temporarily disabled for the variable, so that calls to Tcl_GetVar2 and Tcl_SetVar2 will not cause proc or other trace procedures to be invoked again. 
      
      I expected the trace on "foobar" includes a trace on "foobar(tstkey)" and so 
      the trace is not invoked again. Maybe I'm wrong here?
      
      
      
      Verified.  The problem is that VAR_TRACE_ACTIVE is set for the array, but when setting an element of the array, presence of that flag is only tested for the array element, and traces on the array are blindly executed.  The fix is trivial:  in CallTraces, add a check for VAR_TRACE_ACTIVE on the array before executing traces on the array.  The test suite passes successfully with this modification, but there are no explicit tests of the TCL_TRACE_ARRAY stuff (that feature is currently not exported to Tcl).
      
      I committed this change to CVS; the fix will go out with 8.4a2.  Thanks for finding this bug!
      
         Eric Melski                            The Other Tcl Guy
         ericm at ajubasolutions.com            Ajuba Solutions
      
      -- 07/25/2000 ericm
      
      
      
    4. foundin initialized to: "obsolete: 8.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:
      While in a trace-proc, traces are not disabled for TCL_TRACE
      
    11. type initialized to: "Bug"
  2. Ticket change [6cf610d9ac] (rid 128611) by welch on 2000-10-26 08:34:57:

    1. closedate changed to: "2000-10-26T01:34:57"
    2. closer changed to: "welch"
    3. priority changed to: "2"
    4. resolution changed to: "Fixed"
    5. status changed to: "Closed"
  3. Ticket change [79a8435bbf] (rid 90169) by dgp on 2001-04-20 02:11:54:

    1. closedate changed to: "2001-04-19T19:11:54"
    2. closer changed to: "dgp"
    3. subsystem changed to: "07. Variables"