Index: generic/tclCmdMZ.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclCmdMZ.c,v
retrieving revision 1.82.2.28
diff -u -r1.82.2.28 tclCmdMZ.c
--- generic/tclCmdMZ.c	10 May 2007 18:23:58 -0000	1.82.2.28
+++ generic/tclCmdMZ.c	27 Jun 2007 17:23:59 -0000
@@ -4445,6 +4445,9 @@
 	        active.nextTracePtr = tracePtr;
 	        tracePtr = tracePtr->nextPtr;
             }
+	    if (active.nextTracePtr) {
+		lastTracePtr = active.nextTracePtr->nextPtr;
+	    }
         } else {
 	    active.reverseScan = 0;
 	    active.nextTracePtr = tracePtr->nextPtr;
@@ -4491,9 +4494,6 @@
 	    tracePtr->flags &= ~TCL_TRACE_EXEC_IN_PROGRESS;
 	    Tcl_Release((ClientData) tracePtr);
 	}
-	if (active.nextTracePtr) {
-	    lastTracePtr = active.nextTracePtr->nextPtr;
-	}
     }
     iPtr->activeInterpTracePtr = active.nextPtr;
     return(traceCode);
Index: generic/tclTest.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclTest.c,v
retrieving revision 1.62.2.13
diff -u -r1.62.2.13 tclTest.c
--- generic/tclTest.c	22 Sep 2006 01:26:23 -0000	1.62.2.13
+++ generic/tclTest.c	27 Jun 2007 17:24:00 -0000
@@ -1165,10 +1165,25 @@
 	} else {
 	    return result;
 	}
-	
+    } else if ( strcmp(argv[1], "doubletest" ) == 0 ) {
+	Tcl_Trace t1, t2;
+
+	Tcl_DStringInit(&buffer);
+	t1 = Tcl_CreateTrace(interp, 1,
+		(Tcl_CmdTraceProc *) CmdTraceProc, (ClientData) &buffer);
+	t2 = Tcl_CreateTrace(interp, 50000,
+		(Tcl_CmdTraceProc *) CmdTraceProc, (ClientData) &buffer);
+	result = Tcl_Eval(interp, argv[2]);
+	if (result == TCL_OK) {
+	    Tcl_ResetResult(interp);
+	    Tcl_AppendResult(interp, Tcl_DStringValue(&buffer), NULL);
+	}
+	Tcl_DeleteTrace(interp, t2);
+	Tcl_DeleteTrace(interp, t1);
+	Tcl_DStringFree(&buffer);
     } else {
 	Tcl_AppendResult(interp, "bad option \"", argv[1],
-			 "\": must be tracetest, deletetest or resulttest",
+			 "\": must be tracetest, deletetest, doubletest or resulttest",
 			 (char *) NULL);
 	return TCL_ERROR;
     }
Index: tests/basic.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/basic.test,v
retrieving revision 1.25.2.7
diff -u -r1.25.2.7 basic.test
--- tests/basic.test	18 Mar 2005 16:33:43 -0000	1.25.2.7
+++ tests/basic.test	27 Jun 2007 17:24:01 -0000
@@ -564,6 +564,10 @@
     testcmdtrace leveltest {foo}
 } {foo {foo} {uplevel 1 bar} {uplevel 1 bar} bar {bar} {uplevel 1 grok} {uplevel 1 grok}}
 
+test basic-39.11 {Tcl_CreateTrace, multiple traces} {testcmdtrace} {
+    testcmdtrace doubletest {format xx}
+} {{format xx} {format xx}}
+
 test basic-40.1 {Tcl_DeleteTrace} {emptyTest} {
     # the above tests have tested Tcl_DeleteTrace
 } {}
