<i>Redefining proc ::history locks the interpreter into a tight loop</i> status still Open with 4 other changes
by
.
D 2024-02-03T17:18:58.582
J comment While\sinvestigating\s[fe4d7305a8],\swhich\shas\sbeen\sfixed,\sI\sfound\sanother\sbug.\r\n\r\n::history\sis\sa\sproc\sthat\scalls\sthe\snamespace\sensemble\s::tcl::history\swhose\scomponents\sare\sprocs\s::tcl::Hist*.\s\sAll\sthese\scommands\sare\sdefined\sin\sfile\slibrary/history.tcl,\sare\slisted\s(except\s::tcl::history)\sin\slibrary/tclIndex,\sand\sare\sloaded\son\sdemand\sby\sthe\sautoloader.\r\n\r\nFile\slibrary/history.tcl\salso\ssets\sa\strace\son\scommand\s::history,\sso\sthat\sif\sit\sis\sdeleted,\sall\sthe\srelated\scommands\s::tcl::*\sare\sdeleted,\sand\sthe\sarray\s::tcl::history\sthat\sstores\sthe\scommand\shistory\sis\sunset.\r\n\r\nIf\s::history\sis\srenamed\sor\sdeleted,\sthe\sautoloader\sreloads\sit\swhen\sthe\snext\scommand\sis\sentered\sinto\sthe\sinteractive\sinterpreter.\r\n\r\nThe\suser\sshould\sbe\sable\sto\sredefine\sproc\s::history,\sto\sprovide\san\salternative\sto\sthe\sTcl\sbuilt-in\scommand.\s\sHowever,\sthe\sattempt\smay\scause\sthe\sinterpreter\sto\scease\sfunctioning,\snotably\swhen\sthe\snew\sproc\sis\sidentical\sto\sthe\sold.\s\sThe\sinterpreter\senters\sa\stight\sCPU-consuming\sloop,\sand\snever\sreaches\sthe\spoint\swhere\sit\scan\saccept\sanother\scommand.\r\n\r\nWhat\sseems\sto\sbe\shappening\sis\sthat\sthe\stailcall\sin\s::history\sattempts\sto\sevaluate\s"history"\sin\snamespace\s::tcl,\sexpecting\sto\sevaluate\s::tcl::history,\sbut\sbecause\sthat\scommand\sis\sabsent\sit\sevaluates\s::history\sinstead,\sleading\sto\sinfinite\srecursion.\s\sA\sfix\sis:\r\n\r\n1.\sTo\slist\s::tcl::history\sin\slibrary/tclIndex\r\n\r\n2.\sTo\srequest\s::tcl::history\sexplicitly\sin\sthe\stailcall\r\n\r\nThe\sfix\sis\sin\sthe\sattached\spatch,\swhich\sis\slisted\sbelow.\r\n\r\nOther\smatters:\r\n\r\n(a)\sDoes\sthe\strace\son\s::history\s(deleting\sall\sdependencies\s::tcl::*)\sserve\sany\suseful\spurpose,\sapart\sfrom\ssaving\smemory?\s\sI\ssuggest\sremoving\sit.\r\n\r\n(b)\sThe\sinterpreter\susually\scatches\sinfinite\srecursion.\s\sIn\sthis\scase\sit\sdoes\snot.\r\n\r\nIn\sview\sof\sthe\simportance\sof\s::history,\sI\swould\sappreciate\sreview\sbefore\scommitting\sthis\schange.\s\sIf\snobody\sobjects\sI\swill\salso\sremove\sthe\strace\smentioned\sabove.\r\n\r\n\r\ndiff\s-Naur\soriginal/library/history.tcl\spatched/library/history.tcl\r\n---\soriginal/library/history.tcl\s\s\s\s\s\s\s\s2024-01-18\s17:18:18.000000000\s+0000\r\n+++\spatched/library/history.tcl\s2024-02-03\s16:53:40.144116588\s+0000\r\n@@\s-53,7\s+53,7\s@@\r\n\s\s\s\s\s}\r\n\s\r\n\s\s\s\s\s#\sTricky\sstuff\sneeded\sto\smake\sstack\sand\serrors\scome\sout\sright!\r\n-\s\s\s\stailcall\sapply\s{arglist\s{tailcall\shistory\s{*}$arglist}\s::tcl}\s$args\r\n+\s\s\s\stailcall\sapply\s{arglist\s{tailcall\s::tcl::history\s{*}$arglist}\s::tcl}\s$args\r\n\s}\r\n\s\r\n\r\n\s#\s(unnamed)\s--\r\ndiff\s-Naur\soriginal/library/tclIndex\spatched/library/tclIndex\r\n---\soriginal/library/tclIndex\s\s\s2024-01-18\s17:18:18.000000000\s+0000\r\n+++\spatched/library/tclIndex\s\s\s\s2024-02-03\s16:45:46.591373179\s+0000\r\n@@\s-20,6\s+20,7\s@@\r\n\sset\sauto_index(::auto_mkindex_parser::commandInit)\s[list\ssource\s[file\sjoin\s$dir\sauto.tcl]]\r\n\sset\sauto_index(::auto_mkindex_parser::fullname)\s[list\ssource\s[file\sjoin\s$dir\sauto.tcl]]\r\n\sset\sauto_index(history)\s[list\ssource\s[file\sjoin\s$dir\shistory.tcl]]\r\n+set\sauto_index(::tcl::history)\s[list\ssource\s[file\sjoin\s$dir\shistory.tcl]]\r\n\sset\sauto_index(::tcl::HistAdd)\s[list\ssource\s[file\sjoin\s$dir\shistory.tcl]]\r\n\sset\sauto_index(::tcl::HistKeep)\s[list\ssource\s[file\sjoin\s$dir\shistory.tcl]]\r\n\sset\sauto_index(::tcl::HistClear)\s[list\ssource\s[file\sjoin\s$dir\shistory.tcl]]
J login kjnash
J mimetype text/plain
J type Patch
K 8e666d7c956372d0df195e27d36a53fdbad9164d
U kjnash
Z 7eb64205da563f8dff77e6c3809afabb