Skip to content
Tcl Source Code Artifact [b72e6a29e3]
Login

Artifact [b72e6a29e3]

Artifact b72e6a29e305de82b16061b7f92bad062c03f2fa:

Ticket change [b72e6a29e3] - New ticket [1334947fffffffff|1334947fff] <i>refCounts on PtrSetVar failure</i>. by msofer on 2005-10-22 15:25:12.
D 2005-10-22T15:25:12
J assignee dgp
J cmimetype text/plain
J comment The\srefCount\smanagement\sof\sTclPtrSetVar,\sand\salso\sits\ndifferent\s"front\sends"\sin\stclVar.c,\spresents\sone\nparticular\sproblem\swhich\swas\srevealed\sby\s[Bug\s1191369]\n(both\s8.4\sand\s8.5\sare\sconcerned).\n\nThe\sproblem\sarises\swhen\sthe\snewValuePtr\sobj\shas\srefCount\s0:\n\n(1)\sif\ssetting\sthe\snew\svalue\ssucceeds\sas\srequested,\nnewValuePtr\sgets\sits\srefCount\sincremented\sto\sreflect\nthe\snew\sreference\n\n(2)\sif\ssetting\sthe\snew\svalue\sfails\searly\s(eg,\strying\sto\nset\san\sarray\sto\sa\sscalar\svalue),\snewValuePtr's\srefCount\nis\snot\stouched\s\n\n(3)\sIf\sthere\sis\sa\swrite\strace\sthat\sdoes\snot\sallow\sthe\nvalue\sto\sbe\sset\sas\srequested,\snewValuePtr's\srefCount\nwill\sbe\sincremented/decremented,\sresulting\sin\sit\sbeing\nfreed.\s\n\nThis\srenders\sthe\scaller's\srefCount\smanagement\srather\ncritical,\sas\sreflected\sin\s1191369.\sThere\sare\sother\nspots\sin\sthe\score\swhere\sa\ssimilar\sbug\sis\spresent.\nExample:\sTcl_AddObjErrorInfo\swould\sleak\san\sobj\sif\nerrorCode\sor\serrorInfo\sredefined\sto\sbe\sarrays\s(I\sknow,\nwell\sdeserved);\sTcl_Main\swould\sleak\sif\s"argc"\swas\san\narray.\sWorse,\switness\s(in\sa\sMEM_DEBUG\sHEAD):\n\n%\strace\sadd\svariable\sa\swrite\s{return\s-code\serror\s"RO\nvar";#}\n%\sregexp\sqw\sqwerty\s->\sa\ncouldn't\sset\svariable\s"a"\n%\sset\sa\nfile\s=\s../generic/tclExecute.c,\sline\s=\s2099\nTrying\sto\sincrement\srefCount\sof\spreviously\sdisposed\sobject.\n\n\nThere\sare\stwo\spossible\sfixes:\n\s\n(a)\sfix\sall\scallers\sso\sthat\sthey\sincr\sbefore\scalling,\ndecr\son\sreturn.\sAdd\sa\swarning\sin\sthe\sdocs.\n\n(b)\sfix\sTclPtrSetVar\sso\sthat\sit\sdoes\sincr/decr\sfor\sall\npaths\swhere\sit\sfails\sto\sset\sthe\svalue\sas\srequested,\nallowing\sthe\scallers\sto\sdelegate\sthe\srefCount\nmanagement\sto\sTclPtrSetVar.\sThe\scallers\sstill\shave\sto\nbe\sfixed\sto\snot\stouch\sthat\srefCount.\n\nI\shave\sa\spreference\sfor\s(b);\sassigning\sto\sdgp\sas\sa\nrequest\sfor\sopinion.\sPlease\scomment\sand\sassign\sback.
J foundin obsolete:\s8.4.11
J priority 5\sMedium
J resolution None
J status Open
J submitter msofer
J subsystem 07.\sVariables
J title refCounts\son\sPtrSetVar\sfailure
J type Bug
K 1334947fffffffffffffffffffffffffffffffff
U msofer
Z 71c3a412719ca92df91adc546e58303c