<i>TclDeleteNamespaceVars leaks when unset trace revives var under deletion</i>.
by
.
D 2016-08-31T12:20:31.921
J assignee nobody
J closer nobody
J cmimetype text/plain
J comment When\san\sunset\strace\supon\snamespace\sdeletion\s(TclDeleteNamespaceVars)\sbrings\sback\sa\snamespace\svariable\s(ie.\sdefines\sit\sby\sassigning\sa\svalue),\sthe\scorresponding\sVar(InHash)\sis\snot\sfreed:\r\n\r\n==32261==\s64\sbytes\sin\s1\sblocks\sare\sdefinitely\slost\sin\sloss\srecord\s3\sof\s3\r\n==32261==\s\s\s\sat\s0x4C2BBAD:\smalloc\s(vg_replace_malloc.c:299)\r\n==32261==\s\s\s\sby\s0x4E75392:\sTclpAlloc\s(tclAlloc.c:699)\r\n==32261==\s\s\s\sby\s0x4E8CE23:\sTcl_Alloc\s(tclCkalloc.c:1059)\r\n==32261==\s\s\s\sby\s0x4FE532C:\sAllocVarEntry\s(tclVar.c:6013)\r\n==32261==\s\s\s\sby\s0x4F704D7:\sCreateHashEntry\s(tclHash.c:359)\r\n==32261==\s\s\s\sby\s0x4FDC8AD:\sVarHashCreateVar\s(tclVar.c:63)\r\n==32261==\s\s\s\sby\s0x4FDD7A4:\sTclLookupSimpleVar\s(tclVar.c:853)\r\n==32261==\s\s\s\sby\s0x4FDD130:\sTclObjLookupVarEx\s(tclVar.c:615)\r\n==32261==\s\s\s\sby\s0x4FE2E09:\sTcl_VariableObjCmd\s(tclVar.c:4617)\r\n==32261==\s\s\s\sby\s0x4E80709:\sDispatch\s(tclBasic.c:4358)\r\n==32261==\s\s\s\sby\s0x4E8078F:\sTclNRRunCallbacks\s(tclBasic.c:4391)\r\n==32261==\s\s\s\sby\s0x4E80065:\sTcl_EvalObjv\s(tclBasic.c:4121)\r\n\r\nTo\sreproduce:\r\n\r\n1)\sapply\spatch\r\n2)\srun:\r\n\r\nvalgrind\s--leak-check=full\s--track-origins=yes\s./tcltest\s/usr/local/src/tcl/tests/all.tcl\s-singleproc\s1\s-file\svar.test\r\n\r\n(see\sthe\stest\scase\svar-8.3\sadded\sto\svar.test\sby\sthe\spatch\sattached)\r\n\r\nThe\sproposed\sfix\sis\sto\scall\sTclSetVarUndefined(varPtr)\safter\shaving\striggered\sany\straces,\sas\shinted\sat\sby\sthe\sexisting,\sbut\sunimplemented\scomment:\r\n\r\n"[...]\sforce\sit\s*undefined*\sin\scase\san\sunset\strace\sbrought\sit\sback\sfrom\sthe\sdead."\r\n\r\nWithout\sthat,\sthe\sindirectly\scalled\sFreeVarEntry()\swill\snot\sfree\sthe\srevived\sVar\sin\squestion.\r\nAs\sfar\sas\sI\scan\sjudge,\sthis\saffects\s*all*\sTcl\sversions\s8.5.*,\s8.6.*,\sand\s8.7.*,\sas\sthe\scode\sin\squestion\sappears\sunaltered\sto\sme\sbetween\smajor\sversions.\r\n\r\nThe\sunset\strace\s(in\sthis\stest)\salso\sgives\srise\sto\sa\sLiteralEntry\sleak\s(due\sBC'ing\sthe\sunset\sproc):\r\n\r\n==32261==\s\s\s\sat\s0x4C2BBAD:\smalloc\s(vg_replace_malloc.c:299)\r\n==32261==\s\s\s\sby\s0x4E75392:\sTclpAlloc\s(tclAlloc.c:699)\r\n==32261==\s\s\s\sby\s0x4E8CE23:\sTcl_Alloc\s(tclCkalloc.c:1059)\r\n==32261==\s\s\s\sby\s0x4F9DD86:\sTclCreateLiteral\s(tclLiteral.c:236)\r\n==32261==\s\s\s\sby\s0x4F9E0F4:\sTclRegisterLiteral\s(tclLiteral.c:434)\r\n==32261==\s\s\s\sby\s0x4EE96FF:\sTclCompileSetCmd\s(tclCompCmdsSZ.c:218)\r\n==32261==\s\s\s\sby\s0x4F4B4E8:\sTclAttemptCompileProc\s(tclEnsemble.c:3212)\r\n==32261==\s\s\s\sby\s0x4F2A21A:\sCompileCmdCompileProc\s(tclCompile.c:1950)\r\n==32261==\s\s\s\sby\s0x4F2A820:\sCompileCommandTokens\s(tclCompile.c:2065)\r\n==32261==\s\s\s\sby\s0x4F2ACF4:\sTclCompileScript\s(tclCompile.c:2196)\r\n==32261==\s\s\s\sby\s0x4F2BF9A:\sTclCompileTokens\s(tclCompile.c:2445)\r\n==32261==\s\s\s\sby\s0x4EB093D:\sTclCompileConcatCmd\s(tclCompCmds.c:816)\r\n\r\nDon't\sknow\syet\show\sto\sfix\sthat\sone\s(as\sthe\sliteral\smachinery\ssuch\sas\sTclReleaseLiteral\sis\snot\savailable\sin\sthis\scontext,\sand\sshould\snot\sbe,\smost\sprobably).
J foundin 8.7.0a
J is_private 0
J login mr_calvin
J priority 5\sMedium
J private_contact d4d1d8192a46acf2c7d58cddc1040ecdbc9c9d77
J resolution None
J severity Severe
J status Open
J submitter mr_calvin
J subsystem 07.\sVariables
J title TclDeleteNamespaceVars\sleaks\swhen\sunset\strace\srevives\svar\sunder\sdeletion
J type Bug
K 4dbdd9af1439d874381fd6fdb968bcb0d596f0bb
U mr_calvin
Z 1cf5669944c5e00368640640914e1d50