<i>Tcl crashes after "emptying" a list object with Tcl_SetListO</i>.
by
.
D 2000-10-26T00:55:29
J assignee nobody
J cmimetype text/plain
J comment OriginalBugID:\s3436\sBug\nVersion:\s8.2.1\nSubmitDate:\s'1999-11-05'\nLastModified:\s'1999-11-08'\nSeverity:\sCRIT\nStatus:\sClosed\nSubmitter:\stechsupp\nChangedBy:\shobbs\nOS:\sOther\nFixedDate:\s'2000-10-25'\nClosedDate:\s'1999-11-08'\n\n\nName:\nGeorge\sPetasis\n\nReproducibleScript:\nJust\scompile\sthe\sfollowing\scode\sunder\swindows\swith\svisual\sC++:\n\n#include\s<tcl.h>\n\nint\sAppInit(Tcl_Interp\s*interp);\nint\sBug(ClientData\scd,\sTcl_Interp\s*interp,\sint\sobjc,\sTcl_Obj\s*objv[]);\n\nmain\s(int\sargc,\schar\s*argv[])\s{\n\s\sTcl_Main(argc,\sargv,\sAppInit);\n\s\sreturn\s0;\n}\n\nint\sAppInit(Tcl_Interp\s*interp)\s{\n\s\sif\s(Tcl_CreateObjCommand(interp,\s"bug",\s(Tcl_ObjCmdProc\s*)Bug,\sNULL,\sNULL)\s==\sNULL)\n\s\s\s\s\s\s\s\s\sreturn\sTCL_ERROR;\n\s\sreturn\sTCL_OK;\n}\n\nint\sBug(ClientData\scd,\sTcl_Interp\s*interp,\sint\sobjc,\sTcl_Obj\s*objv[])\s{\n\s\sTcl_Obj\s*Obj,\s*List,\s**Elems;\n\s\schar\stmp[256];\n\s\sint\si,j,k;\n\n\s\sList\s=\sTcl_NewListObj(0,\sNULL);\n\s\sif\s(List\s==\sNULL)\sreturn\sTCL_ERROR;\n\s\sTcl_IncrRefCount(List);\n\n\s\sfor\s(j=0;\sj<100;\sj++)\s{\n\s\s\s\sprintf("->%d\\n",\sj);\n\s\s\s\sfor\s(i=0;\si<10000;\si++)\s{\n\s\s\s\s\s\ssprintf(tmp,\s"Obj-%d-%d",\si,\sj);\n\s\s\s\s\s\sObj\s=\sTcl_NewStringObj(tmp,\s-1);\n\s\s\s\s\s\sif\s(Obj\s==\sNULL)\sreturn\sTCL_ERROR;\n\s\s\s\s\s\sif\s(Tcl_ListObjAppendElement(interp,\sList,\sObj)\s!=\sTCL_OK)\s\n\s\s\s\s\s\s\s\s\s\s\s\s\sreturn\sTCL_ERROR;\n\s\s\s\s}\n\n\s\s\s\sObj\s=\sTcl_NewStringObj(Tcl_GetString(List),\s-1);\s\n\s\s\s\sTcl_SetListObj(List,\s0,\sNULL);\n\s\s\s\sTcl_DecrRefCount(List);\sTcl_IncrRefCount(Obj);\n\s\s\s\sTcl_ListObjGetElements(interp,\sObj,\s&k,\s&Elems);\n\s\s\s\sTcl_IncrRefCount(Elems[10]);\s/*\s<<\sthat\sdoes\sthe\strick!\s*/\n\s\s\s\sTcl_SetListObj(Obj,\s0,\sNULL);\n\s\s\s\sTcl_DecrRefCount(Obj);\n\s\s}\n\s\sreturn\sTCL_OK;\n}\n\nrun\sthe\sexecutable\sand\stype\s"bug".\s\n(Note\sthat\sunder\swindows\s98\sthe\ssystem\smay\sbecome\sunstable\nand\sthe\suser\shas\sto\sreboot\sthe\spc...)\n\nObservedBehavior:\nThis\scode\scause\san\sillegal\sinstruction\son\sboth\swindows\s98\sSE\sand\sNT\s4.0\sSP5\nwhere\sit\swas\stested.\sIf\sthe\sapplication\sis\sbuilt\sas\sa\sconsole\sapplication,\sfrom\nthe\sprintf\sstatement\swe\sget\sthat\sit\scrashes\sat\sj=2.\sIt\sseems\sthat\sTcl_SetListObj\ncannot\shandle\sproperly\slist\sobjects,\ssome\selements\sof\swhich\sare\sshared.\nThis\sproblem\sis\snot\sreproducable\sunder\sunix\sthough,\swhich\sis\squite\sstrange.\nBut\sit\smight\sbe\srelated\swith\sthe\sother\sbug\sreport\sthat\sI\shave\ssubmitted\swith\stitle\n"[Bug\sTcl\s8.2.1]\sPossible\sBug\sin\sinternal\smemory\smanagement\sof\sthe\sTcl_Obj\s*\sstructure".\n(also\sthere\swas\sa\ssmall\smistake\sin\sthat\sreport.\sIn\sorder\sfor\sthe\sbug\sto\shappen,\s\none\smust\suse\sthe\sfollowing\sscript:\n\nfor\s{set\si\s0}\s{$i\s<\s10}\s{incr\si}\s{\n\s\s\sforeach\scmd\s[info\scommands]\s{\n\s\s\s\s\slappend\slist\s$cmd\n\s\s}\n}\nBug\s$list\n)\n\n\n\nThis\swas\sdue\sto\sincorrect\suse\sof\sobjects,\sthe\sfix\swas\smentioned\non\sthe\snewsgroup.\s\n--\s11/08/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 Tcl\scrashes\safter\s"emptying"\sa\slist\sobject\swith\sTcl_SetListO
J type Bug
K 218283ffffffffffffffffffffffffffffffffff
U nobody
Z 4f43d6b92869afea0c6603a4a815065b