.
D 2000-10-26T00:55:23
J assignee nobody
J cmimetype text/plain
J comment OriginalBugID:\s3387\sBug\nVersion:\s8.2.1\nSubmitDate:\s'1999-11-05'\nLastModified:\s'2000-02-25'\nSeverity:\sCRIT\nStatus:\sClosed\nSubmitter:\stechsupp\nChangedBy:\shobbs\nOS:\sOther\nOSVersion:\sRedhat\slinux\s6.1,\sSolaris\s2.6\nFixedDate:\s'2000-10-25'\nClosedDate:\s'2000-02-25'\n\n\nName:\nGeorgios\sPetasis\n\nReproducibleScript:\nMake\san\sextension\s(e.g.\sa\sdynamic\slibrary)\susing\sthis\scode:\n\n####\sStart\sof\sCode...\n/*\sFunction:\sBug\s*/\nint\sBug(\sClientData\sclientData,\sTcl_Interp\s*interp,\sint\sobjc,\sTcl_Obj\s*objv[])\s{\n\s\sTcl_Channel\sFile;\n\s\sTcl_Obj\s*LineObj,\s**elemPtrs;\n\s\schar\s*Line;\n\s\sint\si,\schars,\slistLen;\n\n\s\sFile\s=\sTcl_OpenFileChannel(interp,\s"Temp.txt",\s"w",\s0666);\n\s\sif\s(File\s==\sNULL)\sreturn\sTCL_ERROR;\n\s\s/*\sWrite\seach\sgiven\sobject\s2\stimes...\s*/\n\s\sfor\s(i=0;\si<objc;\si++)\s{\n\s\s\s\sTcl_WriteChars(File,\sTcl_GetString(objv[i]),\s-1);\n\s\s\s\sTcl_WriteChars(File,\s"\\n",\s1);\n\s\s\s\sTcl_WriteChars(File,\sTcl_GetString(objv[i]),\s-1);\n\s\s\s\sTcl_WriteChars(File,\s"\\n",\s1);\n\s\s}\n\s\sif\s(Tcl_Close(interp,\sFile)\s!=\sTCL_OK)\sreturn\sTCL_ERROR;\n\n\s\sFile\s=\sTcl_OpenFileChannel(interp,\s"Temp.txt",\s"r",\s0666);\n\s\sif\s(File\s==\sNULL)\sreturn\sTCL_ERROR;\n\n\s\sLineObj\s=\sTcl_NewObj();\n\s\sif\s(LineObj\s==\sNULL)\s{printf("out\sof\smemory\\n");\sexit;}\n\s\sTcl_IncrRefCount(LineObj);\schars\s=\s1;\n\n\s\swhile\s(chars\s>\s0)\s{\n\s\s\s\sTcl_SetObjLength(LineObj,\s0);//\sEmpty\sobject,\sbut\skeep\sallocated\sspace...\n\s\s\s\sprintf("now\sreading\sobjects...\\n");\n\s\s\s\schars\s=\sTcl_GetsObj(File,\sLineObj);\sif\s(chars<0\s||\sTcl_Eof(File))\nbreak;\n\s\s\s\sLine\s=\sTcl_GetString(LineObj);\n\s\s\s\si\s=\sTcl_ListObjGetElements(interp,\sLineObj,\s&listLen,\s&elemPtrs);\n\s\s\s\sif\s(i\s==\sTCL_OK)\s{\n\s\s\s\s\s\sprintf("list:\s%s\\n",\sTcl_GetString(LineObj));\n\s\s\s\s\s\sTcl_SetListObj(LineObj,\s0,\sNULL);\s/*\sEmpty\sList\sobj\s*/\n\s\s\s\s}\n\s\s\s\selse\s\s\s\s\s\s\s\s\s\s\s\s\sprintf("string:\s%s\\n",\sTcl_GetString(LineObj));\n\s\s\s\sprintf("now\sreading\schars...\\n");\n\s\s\s\schars\s=\sTcl_ReadChars(File,\sLineObj,\sstrlen(Tcl_GetString(LineObj)),\n0);\n\s\s\s\sif\s(chars<0\s||\sTcl_Eof(File))\sbreak;\n\s\s\s\schars\s=\sTcl_ReadChars(File,\sLineObj,\s1,\s1);\s/*\sread\snew-line\s*/\n\s\s\s\si\s=\sTcl_ListObjGetElements(interp,\sLineObj,\s&listLen,\s&elemPtrs);\n\s\s\s\sif\s(i\s==\sTCL_OK)\s{\n\s\s\s\s\s\sprintf("list:\s%s\\n",\sTcl_GetString(LineObj));\n\s\s\s\s\s\sTcl_SetListObj(LineObj,\s0,\sNULL);\s/*\sEmpty\sList\sobj\s*/\n\s\s\s\s}\n\s\s\s\selse\s\s\s\s\s\s\s\s\s\s\s\s\sprintf("string:\s%s\\n",\sTcl_GetString(LineObj));\n\s\s}\n\s\sprintf("Now\sthe\score...\\n");\n\s\sif\s(Tcl_Close(interp,\sFile)\s!=\sTCL_OK)\sreturn\sTCL_ERROR;\n\s\sTcl_DecrRefCount(LineObj);\n\s\sprintf("Still\sAlive???????????????\\n");\n\s\sreturn\sTCL_OK;\n}\s/*\sBug\s*/\n##\sEnd\sof\sCode...\n\n\s\s\s\sand\sinside\stcl\sinvoke\sthe\scommand\swith\sa\squite\slengthy\slist:\sa\s"Bug\n\s\s\s\s[info\scommands]"\swill\sdo\sthe\strick...\n\nObservedBehavior:\nSeems\sthat\sTcl\shas\sproblem\susing\sTcl_SetListObj\sand\sTcl_SetObjLength\son\n\s\s\s\sthe\ssame\n\s\s\s\sobject.\sWhen\strying\sto\sfree\sthat\sobject\sit\scrashes.\sIn\sthis\ssmall\n\s\s\s\sexample,\sTcl\scrashes\swhile\n\s\s\s\sprocessing\sthe\slist,\sbut\sin\smy\sapplication\sIt\scrashes\swhen\sclosing\sthe\n\s\s\s\sfile\s(in\sTcl_Eventually_Free\ssomething\n\s\s\s\sinside\sTcl_Close).\sIn\sthis\slitlle\sprogram\sit\scrashes\sinside\n\s\s\s\sTcl_ReadChars:\n\n\s\s\s\s#0\s\s0xef5ebec4\sin\sSetStringFromAny\s()\n\s\s\s\s#1\s\s0xef5eb638\sin\sTcl_SetObjLength\s()\n\s\s\s\s#2\s\s0xef5d0ba8\sin\sTcl_ReadChars\s()\n\n\s\s\s\sUsing\s2\sdifferent\sobjects\ssolves\sthe\sproblem\s(at\sleast\sin\sthis\ssmall\n\s\s\s\sexample).\n\n\s\s\s\sI\sthink\sthat\sthis\ssmall\sexample\smay\snot\scatch\sthe\sentire\sproblem\s(but\sit\n\s\s\s\smay\sbe\sa\sgood\sstart...)\n\s\s\s\sMy\sapplication\sstill\scrashes\swhen\stries\sto\sfree\ssome\sobjects\sthat\shold\n\s\s\s\slists\n\s\s\s\s(created\swith\sTcl_NewListObj)\sand\shave\sas\selements\sother\slists.\sAll\n\s\s\s\sitems\screated\n\s\s\s\swith\sTcl_NewListObj\sand\saccessed/modified\sonly\sthrough\sTcl_***\n\s\s\s\sfunctions.\sI\sreally\scannot\n\s\s\s\sunderstand\swhy\stcl\scrashes...\n\nDesiredBehavior:\nThe\ssame\sTcl_obj\sbe\sused\seither\sas\sa\slist\sor\sas\sa\sstring\swithout\n\s\s\s\sproblem.\sI\smean\sthat\sthe\sman\n\s\s\s\spages\sdo\snot\ssay\sthat\son\sobject\sshould\sbe\sused\sonly\sas\sa\sstring\sor\sas\sa\n\s\s\s\slist...\sIs\sthat\scorrect?\n\n\n\nCould\sbe\srelated\sto\sTcl_UnstackChannel\sbug\sfix\sfrom\sAndreas\nKupries\s(not\syet\sapplied).\s\n--\s11/09/1999\shobbs\nNot\sverifiable\sby\ssomeone\sone\sthe\snet\n\s\s\s\shttp://www.deja.com/=dnc/viewthread.xp?AN=537850495\s\n--\s11/17/1999\shobbs
J foundin obsolete:\s8.2.1
J priority 5\sMedium
J resolution None
J status Open
J submitter nobody
J subsystem 10.\sObjects
J title Possible\sBug\sin\sinternal\smemory\smanagement\sof\sthe\sTcl_Obj\s*\s
J type Bug
K 218278ffffffffffffffffffffffffffffffffff
U nobody
Z 711b1e820aa9305b01beee8b38b66251