.
D 2000-10-26T00:46:10
J assignee nobody
J cmimetype text/plain
J comment OriginalBugID:\s3392\sBug\nVersion:\s8.2.1\nSubmitDate:\s'1999-11-05'\nLastModified:\s'1999-11-08'\nSeverity:\sCRIT\nStatus:\sClosed\nSubmitter:\stechsupp\nChangedBy:\shobbs\nRelatedBugIDs:\s3396\nOS:\sWindows\sNT\nOSVersion:\s4.0\nFixedDate:\s'2000-10-25'\nClosedDate:\s'1999-11-08'\n\n\nName:\nKory\sHopkins\n\nReproducibleScript:\nJust\scompile\sand\srun\sthis\s.cpp\sfile:\n\s\s\s\s\n\s\s\s\sextern\s"C"\s{\n\s\s\s\s#include\s"Tcl.h"\n\s\s\s\s#include\s"tclInt.h"\n\s\s\s\sEXTERN\svoidTclpInitLibraryPath\s_ANSI_ARGS_((CONST\schar\s*argv0));\n\s\s\s\s}\n\s\s\s\s\n\s\s\s\svoid\smain()\n\s\s\s\s{\n\s\s\s\sTcl_Interp*\stheInterpreter_p;\n\s\s\s\sTcl_Obj*\stheTclStrObj_p1,\s*theTclStrObj_p2;\n\s\s\s\s\n\s\s\s\sTclpInitLibraryPath(NULL);\n\s\s\s\s\n\s\s\s\stheInterpreter_p\s=\sTcl_CreateInterp();\n\s\s\s\s\n\s\s\s\sif\s(theInterpreter_p\s==\s0)\n\s\s\s\sthrow\s0;\n\s\s\s\s\n\s\s\s\sif\s(\sTcl_Init(theInterpreter_p)\s!=\sTCL_OK\s)\n\s\s\s\sthrow\s0;\n\s\s\s\s\n\s\s\s\s//\n\s\s\s\s//\sDo\sthe\sfirst\sset.\s\sThis\sworks\sfine.\n\s\s\s\s//\n\s\s\s\stheTclStrObj_p1\s=\sTcl_NewStringObj("set\sone\sa",\s-1);\n\s\s\s\s\n\s\s\s\sTcl_EvalObj(theInterpreter_p,\stheTclStrObj_p1);\n\s\s\s\sTcl_DecrRefCount(theTclStrObj_p1);\n\s\s\s\s\n\s\s\s\s//\n\s\s\s\s//\sDo\ssecond\sset.\s\sSomehow\stheTclStrObj_p2->refCount\sis\sincremented\sat\n\s\s\s\sthe\s\n\s\s\s\s//\sfollowing\slocations\s(I\sdidn't\ssearch\sall\sthe\sway\sdown\sbut\sthis\sis\n\s\s\s\sthe\n\s\s\s\s//\sstack\swhere\sI\sstopped\ssearching):\n\s\s\s\s//\n\s\s\s\s//\sinside\stclBasic.c:\sTcl_EvalObjEx()\sat\sthe\sfollowing\sline:\n\s\s\s\s//result\s=\stclByteCodeType.setFromAnyProc(interp,\sobjPtr);\n\s\s\s\s//\n\s\s\s\s//\ssetFromAnyProc()\scalls\sTclSetByteCodeFromAny()\n\s\s\s\s//\n\s\s\s\s//\sinside\stclCompile.c:\sTclSetByteCodeFromAny()\sat\sthe\sfollowing\sline:\n\s\s\s\s//result\s=\sTclCompileScript(interp,\sstring,\slength,\snested,\n\s\s\s\s&compEnv);\n\s\s\s\s//\n\s\s\s\s//\n\s\s\s\s//\sSo,\sif\syou\sjust\slet\sthis\scode\srun\sthe\sstack\swill\seventualy\soverflow\n\s\s\s\s//\swith\sthese\sfour\sfunction\sbeing\scalled\srecursively\sfilling\sup\sthe\n\s\s\s\sstack:\n\s\s\s\s//\n\s\s\s\s//\sTclFreeObj()\n\s\s\s\s//\sFreeByteCodeInternalRep()\n\s\s\s\s//\sTclCleanupByteCode()\n\s\s\s\s//\sTclReleaseLiteral()\n\s\s\s\s//\sTclFreeObj()\n\s\s\s\s//\s....\n\s\s\s\s//\n\s\s\s\stheTclStrObj_p2\s=\sTcl_NewStringObj("set\stwo\sb",\s-1);\n\s\s\s\s\n\s\s\s\sTcl_EvalObj(theInterpreter_p,\stheTclStrObj_p2);\n\s\s\s\sTcl_DecrRefCount(theTclStrObj_p2);\n\s\s\s\s}\n\nObservedBehavior:\nSee\scomments\sin\scode:\n\s\s\s\s\n\s\s\s\s//\sDo\ssecond\sset.\s\sSomehow\stheTclStrObj_p2->refCount\sis\sincremented\sat\n\s\s\s\sthe\s\n\s\s\s\s//\sfollowing\slocations\s(I\sdidn't\ssearch\sall\sthe\sway\sdown\sbut\sthis\sis\n\s\s\s\sthe\n\s\s\s\s//\sstack\swhere\sI\sstopped\ssearching):\n\s\s\s\s//\n\s\s\s\s//\sinside\stclBasic.c:\sTcl_EvalObjEx()\sat\sthe\sfollowing\sline:\n\s\s\s\s//result\s=\stclByteCodeType.setFromAnyProc(interp,\sobjPtr);\n\s\s\s\s//\n\s\s\s\s//\ssetFromAnyProc()\scalls\sTclSetByteCodeFromAny()\n\s\s\s\s//\n\s\s\s\s//\sinside\stclCompile.c:\sTclSetByteCodeFromAny()\sat\sthe\sfollowing\sline:\n\s\s\s\s//result\s=\sTclCompileScript(interp,\sstring,\slength,\snested,\n\s\s\s\s&compEnv);\n\s\s\s\s//\n\s\s\s\s//\n\s\s\s\s//\sSo,\sif\syou\sjust\slet\sthis\scode\srun\sthe\sstack\swill\seventualy\soverflow\n\s\s\s\s//\swith\sthese\sfour\sfunction\sbeing\scalled\srecursively\sfilling\sup\sthe\n\s\s\s\sstack:\n\s\s\s\s//\n\s\s\s\s//\sTclFreeObj()\n\s\s\s\s//\sFreeByteCodeInternalRep()\n\s\s\s\s//\sTclCleanupByteCode()\n\s\s\s\s//\sTclReleaseLiteral()\n\s\s\s\s//\sTclFreeObj()\n\s\s\s\s//\s....\n\s\s\s\s//\n\nDesiredBehavior:\nThe\sobject\sshould\sonly\shave\sits\srefcount\sincremented\sto\s1,\snot\s2.\n\s\s\s\sBecause,\sits\s2\sI\sam\sassuming\sthat\sthis\sis\scausing\sthe\sinfinite\sloop.\n\n\n\n
J foundin obsolete:\s8.2.1
J priority 5\sMedium
J resolution None
J status Open
J submitter nobody
J subsystem 69.\sOther
J title Stack\soverflow\sbecause\sof\sbad\srefCount
J type Bug
K 217929ffffffffffffffffffffffffffffffffff
U nobody
Z 6bc108b7ea57a6cb337de892fe626a8c