From a4532de5a0c31242de9ceae9dd4caf529fe8c9c8 Mon Sep 17 00:00:00 2001 From: dgp Date: Fri, 10 Jun 2016 13:43:13 +0000 Subject: Corrects reported bug, but makes many tests fail. Something subtle about what we should expect when recording the line of a command that isn't known until runtime. --- generic/tclCompile.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/generic/tclCompile.c b/generic/tclCompile.c index 5030f89..8cdd9d2 100644 --- a/generic/tclCompile.c +++ b/generic/tclCompile.c @@ -2602,8 +2602,12 @@ EnterCmdWordData( TclAdvanceLines (&wordLine, last, tokenPtr->start); TclAdvanceContinuations (&wordLine, &wordNext, tokenPtr->start - envPtr->source); +#if 0 wwlines[wordIdx] = (TclWordKnownAtCompileTime(tokenPtr, NULL) ? wordLine : -1); +#else + wwlines[wordIdx] = wordLine; +#endif ePtr->line[wordIdx] = wordLine; ePtr->next[wordIdx] = wordNext; last = tokenPtr->start; -- cgit v0.12 From d418226edb26ced6ce6d46dffe7364795280f48e Mon Sep 17 00:00:00 2001 From: dgp Date: Thu, 16 Jun 2016 16:59:09 +0000 Subject: Improve fix and add test. --- generic/tclCompile.c | 7 ++----- tests/info.test | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/generic/tclCompile.c b/generic/tclCompile.c index 8cdd9d2..31e69ad 100644 --- a/generic/tclCompile.c +++ b/generic/tclCompile.c @@ -2602,12 +2602,9 @@ EnterCmdWordData( TclAdvanceLines (&wordLine, last, tokenPtr->start); TclAdvanceContinuations (&wordLine, &wordNext, tokenPtr->start - envPtr->source); -#if 0 wwlines[wordIdx] = - (TclWordKnownAtCompileTime(tokenPtr, NULL) ? wordLine : -1); -#else - wwlines[wordIdx] = wordLine; -#endif + ((wordIdx == 0) || TclWordKnownAtCompileTime(tokenPtr, NULL)) + ? wordLine : -1; ePtr->line[wordIdx] = wordLine; ePtr->next[wordIdx] = wordNext; last = tokenPtr->start; diff --git a/tests/info.test b/tests/info.test index 937da8c..d30bf9a 100644 --- a/tests/info.test +++ b/tests/info.test @@ -1818,6 +1818,23 @@ test info-38.2 {location information for uplevel, dl, direct-literal} -match glo * {type source line 1814 file info.test cmd etrace level 1} * {type source line 1812 file info.test cmd uplevel\\ \\\\ level 1}} -cleanup {interp delete sub} +test info-39.0 {Bug 4b61afd660} -setup { + proc probe {} { + return [dict get [info frame -1] line] + } + set body { + set cmd probe + $cmd + } + proc demo {} $body +} -body { + demo +} -cleanup { + unset -nocomplain body + rename demo {} + rename probe {} +} -result 3 + # cleanup catch {namespace delete test_ns_info1 test_ns_info2} ::tcltest::cleanupTests -- cgit v0.12 From fa88074963b9c9551a70632a1052b949a9b6b063 Mon Sep 17 00:00:00 2001 From: dgp Date: Thu, 16 Jun 2016 17:06:25 +0000 Subject: [16828b3744] [vwait] *must* successfully undo its variable trace, or else it risks corrupting memory. Namespace teardown complexities were giving the traces an opportunity to survive. Added another (arguably better) Tcl_UntraceVar() call to be sure we avoid this problem. --- generic/tclEvent.c | 2 ++ tests/event.test | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/generic/tclEvent.c b/generic/tclEvent.c index c664b38..4db524c 100644 --- a/generic/tclEvent.c +++ b/generic/tclEvent.c @@ -1379,6 +1379,8 @@ VwaitVarProc( int *donePtr = (int *) clientData; *donePtr = 1; + Tcl_UntraceVar(interp, name1, TCL_TRACE_WRITES|TCL_TRACE_UNSETS, + VwaitVarProc, clientData); return NULL; } diff --git a/tests/event.test b/tests/event.test index a7122f9..4996b97 100644 --- a/tests/event.test +++ b/tests/event.test @@ -559,6 +559,15 @@ test event-11.6 {Tcl_VwaitCmd procedure: round robin scheduling, same source} { removeFile $test2file list $x $y $z } {3 3 done} +test event-11.7 {Bug 16828b3744} { + after idle { + set ::t::v 1 + namespace delete ::t + } + namespace eval ::t { + vwait ::t::v + } +} {} test event-12.1 {Tcl_UpdateCmd procedure} { -- cgit v0.12