Infinite Loop when Debugging through Logger library

Posted by a093130 on 2016-03-13 21:03
Forums: TDK discussion | OS: Windows 8

TclDevKit5.4.1.299366-win32-ix86-threaded
Tcl 8.6.4
Tcllib 1.17
Windows 10 Pro - 64 bit

I am debugging code that uses the tcl logger library. Pertinent code is as follows:

package require logger

# Global Logger Creation
set log [logger::init global]

# Initialize a log file channel for each severity level.
foreach lvl [logger::levels] {
interp alias {} DispAndLogIt_$lvl {} mccnet::DispAndLogIt $lvl
${log}::logproc $lvl DispAndLogIt_$lvl
}

proc OnGo {} {
global log
${log}::info "Operator has selected Go button."
}

The logging code runs perfectly outside the TDK debugger. When I try to F5 run the code, or F7 step over the logging statement, I get an infinite loop in the callback.

My stack trace looks like this:
level Type Name Args
0 global
1 proc OnGo
2 proc logger::tree::global::infocmd args
3 uplevel
2 proc logger::tree::global::infocmd args
3 uplevel
2 proc logger::tree::global::infocmd args
3 uplevel
.... and so on, 123 iterations until I get "Error: too many nested evaluations (infinite loop?).

The error details log is:
too many nested evaluations (infinite loop?)
while executing
"::info vars"
("uplevel" body line 1)
invoked from within
"DbgNub_uplevelCmd #$level "$DbgNub(scope)info vars""
(procedure "DbgNub_GetVariables" line 8)
invoked from within
"DbgNub_GetVariables 0 {}"
("eval" body line 1)
invoked from within
"eval [lindex $msg 2]"
invoked from within
"# Compiled -- no source code available
error "called a copy of a compiled script""
(procedure "::dbgtalk::Snit_methodgetVariables" line 1)
invoked from within
"$dbg getVariables $level $vars"
(procedure "::varCache::Snit_methodlist" line 17)
invoked from within
"$vcache list [mymethod isArrayExpanded] $level"
(procedure "::var::Snit_methodupdateWindow" line 10)
invoked from within
"$varwin updateWindow"
(procedure "::stackWin::Snit_methodupdateDbgWindow" line 28)
invoked from within
"$self updateDbgWindow "
(procedure "::stackWin::Snit_methodcheckState" line 7)
invoked from within
".mainDbgWin.engines.1.uie.data.stack checkState .mainDbgWin.engines.1.uie.data.stack.icoList"
("uplevel" body line 1)
invoked from within
"uplevel 1 [linsert $args 0 $self]"
invoked from within
"::snit::RT.CallInstance ::stackWin::Snit_inst1 checkState .mainDbgWin.engines.1.uie.data.stack.icoList"
("eval" body line 1)
invoked from within
"eval [linsert $options(-onselect) end $self]"
(procedure "::icolist::Snit_methodOnSelection" line 7)
invoked from within
".mainDbgWin.engines.1.uie.data.stack.icoList OnSelection"
("uplevel" body line 1)
invoked from within
"uplevel 1 [linsert $args 0 $self]"
invoked from within
"::snit::RT.CallInstance ::icolist::Snit_inst1 OnSelection"
( binding on .mainDbgWin.engines.1.uie.data.stack.icoList.l.t)

The debug error is at this point in the following dynamic code.

proc infocmd args {
uplevel 1 [list LogIt_info [expr {[llength $args]==1 ? [lindex $args end] : $args}]]
}

The debugger highlights "expr {[llength $args]==1 ? [lindex $args end] : $args}"

If I turn off dynamic instrumentation, the logging callback is in fact called,
with logger output:
2016-03-12T07:07:36 info UnitTest4.1: function function -type -name -args
2016-03-12T07:07:36 info UnitTest4.1: function {Operator has selected Go button.} -type -name -args
2016-03-12T07:07:36 info UnitTest4.1: function function -type -name -args
2016-03-12T07:07:36 info UnitTest4.1: function function -type -name -args
2016-03-12T07:07:36 info UnitTest4.1: function function -type -name -args
2016-03-12T07:07:36 info UnitTest4.1: function function -type -name -args
2016-03-12T07:07:36 info UnitTest4.1: function function -type -name -args
2016-03-12T07:07:36 info UnitTest4.1: function function -type -name -args
2016-03-12T07:07:36 info UnitTest4.1: function function -type -name -args
2016-03-12T07:07:36 info UnitTest4.1: function {Operator has selected Go button.} -type -name -args
...
the number of messages "2016-03-12T07:07:36 info UnitTest4.1: function function -type -name -args" doubling + 1 each time

Any suggestions?