Overview
| Artifact ID: | bb33c9e14cefd5d7fa7daed69f70784ec7cd022b |
|---|---|
| Ticket: | 219113ffffffffffffffffffffffffffffffffff
While in a trace-proc, traces are not disabled for TCL_TRACE |
| User & Date: | nobody on 2000-10-26 01:10:59 |
Changes
- assignee changed to: "nobody"
- cmimetype changed to: "text/plain"
- comment changed 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 - foundin changed to: "obsolete: 8.3"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "nobody"
- subsystem changed to: "69. Other"
- title changed to:
While in a trace-proc, traces are not disabled for TCL_TRACE
- type changed to: "Bug"