.
D 2000-10-26T01:01:20
J assignee nobody
J cmimetype text/plain
J comment OriginalBugID:\s719\sBug\nVersion:\s8.0.3\nSubmitDate:\s'1998-10-13'\nLastModified:\s'1999-12-03'\nSeverity:\sSER\nStatus:\sReleased\nSubmitter:\sadmin\nChangedBy:\shobbs\nOS:\sSolaris\nOSVersion:\sNA\nMachine:\sNA\nFixedDate:\s'1999-12-03'\nFixedInVersion:\s8.2\nClosedDate:\s'2000-10-25'\n\n\nSynopsis:\sTcl_ObjSetVar2(...,\sTCL_LEAVE_ERR_MSG)\sclears\sinterp->result\nwhen\snew\svariable\sis\screated\n\nReproducibleScript:\s\s/*\n\s*\sDemo\sprogram\sfor\sbug\sin\sTcl_ObjSetVar2()\sTcl\s8.0,\s8.0p1,\s8.0p2\sand\s8.0.3\n\s*\n\s*\sReally\sbug\sin\sTclLookupVar()\son\sline\s214\sof\stclVar.c\swhere\n\s*\sTcl_ResetResult()\sis\scalled\seven\sthough\sthe\svariable\screation\n\s*\smay\syet\ssucceed!\n\s*/\n#include\s<stdio.h>\n#include\s<tcl.h>\n\n#define\sMAKE_OBJ(name,\sval)\s\sTcl_Obj\s*name\s=\sTcl_NewStringObj(val,\ssizeof(val)-1)\n\nstatic\sint\sAppInit(Tcl_Interp\s*interp)\n{\n\s\s\s\sint\sok;\n\s\s\s\sMAKE_OBJ(obj,\s"newVar");\n\s\s\s\sMAKE_OBJ(cmdObj,\s"list\s1\s+\s2\s+\s3");\n\n\s\s\s\sif\s(Tcl_Init(interp)\s!=\sTCL_OK)\n\s\s\s\s\s\s\s\sreturn\sTCL_ERROR;\n\n\s\s\s\s/*\n\s\s\s\s\s*\sBreaks\sthe\sfirst\stime\swhen\svariable\sneeds\sto\sbe\screated!\n\s\s\s\s\s*/\n\s\s\s\sif\s(Tcl_EvalObj(interp,\scmdObj)\s!=\sTCL_OK)\n\s\s\s\s\s\s\s\sreturn\sTCL_ERROR;\n\n\s\s\s\sif\s(Tcl_ObjSetVar2(interp,\sobj,\sNULL,\sTcl_GetObjResult(interp),\n\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\sTCL_PARSE_PART1|TCL_LEAVE_ERR_MSG)\s==\sNULL)\n\s\s\s\s\s\s\s\sreturn\sTCL_ERROR;\n\n\s\s\s\sif\s(Tcl_VarEval(interp,\s"puts\s-nonewline\s{Value\sis\sempty:\s}\\n",\n\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s"puts\s'$newVar'\\n",\s(char\s*)0)\s!=\sTCL_OK)\n\s\s\s\s\s\s\s\sreturn\sTCL_ERROR;\n\n\s\s\s\s/*\n\s\s\s\s\s*\sWorks\sthe\ssecond\stime\swhen\svariable\salready\sexists!\n\s\s\s\s\s*/\n\s\s\s\sif\s(Tcl_EvalObj(interp,\scmdObj)\s!=\sTCL_OK)\n\s\s\s\s\s\s\s\sreturn\sTCL_ERROR;\n\n\s\s\s\sif\s(Tcl_ObjSetVar2(interp,\sobj,\sNULL,\sTcl_GetObjResult(interp),\n\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\sTCL_PARSE_PART1|TCL_LEAVE_ERR_MSG)\s==\sNULL)\n\s\s\s\s\s\s\s\sreturn\sTCL_ERROR;\n\n\s\s\s\sif\s(Tcl_VarEval(interp,\s"puts\s-nonewline\s{Value\sis\scorrect:\s}\\n",\n\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s"puts\s'$newVar'\\n",\s(char\s*)0)\s!=\sTCL_OK)\n\s\s\s\s\s\s\s\sreturn\sTCL_ERROR;\n\n\s\s\s\sreturn\sTcl_VarEval(interp,\s"exit\s0",\s(char\s*)0);\n}\n\nint\smain(int\sargc,\schar\s*argv[])\n{\n\s\s\s\sTcl_Main(argc,\sargv,\sAppInit);\n\s\s\s\sreturn\s1;\n}\n\nObservedBehavior:\sCreation\sof\snew\svariables\swith\sTCL_LEAVE_ERR_MSG\nclobbers\sinterpreter\sresult\seven\swhen\svariable\screation\ssucceeds.\s\sI\ndo\snot\sbelieve\sthis\smatches\sthe\sdesired\ssemantics.\n\nDesiredBehavior:\sThe\sinterpreter\sresult\sshould\sbe\smodified\sonly\son\nerror.\n\nPatch:\sI\sdo\snot\shave\sa\spatch\sthat\sI\sam\ssure\swill\swork.\s\sThe\sbug\sis\son\nline\s214\sof\stclVar.c\swhere\sTcl_ResetResult(interp)\sis\scalled\sbefore\nthe\svariable\screation\sis\sattempted.\s\sI\sthink\sthis\scode\scould\sbe\smoved\nlower\sor\sremoved...\sbut\sthe\simplications\sfor\sthe\sfunctions\scalled\sto\ncreate\sthe\svariable\sare\snot\sclear\sto\sme.\n\nComments:\sCropped\sup\swhile\strying\sto\sfix\s"catch"\sto\sreport\sa\sproper\nerror\smessage\swhen\sunable\sto\sset\sresult\svariables.\s\sThe\scurrent\ngeneric\smessage\sis\salso\sa\sbug,\strivial\sto\sfix\sif\sit\swere\snot\sfor\sthe\nSetVar2\sproblem.\n\n\n\nTcl_ResetResult\sis\snot\scalled\sat\sall\sin\sTclLookupVar\sas\sof\s8.2.\s\n--\s12/03/1999\shobbs
J foundin obsolete:\s8.0.3
J priority 5\sMedium
J resolution None
J status Open
J submitter nobody
J subsystem 10.\sObjects
J title Tcl_ObjSetVar2\serroneously\sclears\sinterp->result\swhen\snew\sva
J type Bug
K 218497ffffffffffffffffffffffffffffffffff
U nobody
Z 5dd241c30d6ecd3da44348715692bc07