.
D 2005-02-09T15:52:04
J assignee msofer
J cmimetype text/plain
J comment There\sis\sa\sproblem\swith\sthe\sinternal\shandling\sof\sTcl\scommand\s\nobjects\sthat\sexposes\sit\sto\sa\ssegmentation\sfault.\s\nThe\sroot\sof\sthe\sproblem\sseems\sto\sbe\sthat\sdescendants\sof\s\nTcl_EvalObjEx()\smakes\san\simplicit\sassumption\sthat\sthe\slist\s\nelements\sof\sobjPtr\swill\snot\sbe\sfreed.\s\sBut\sTclCompEvalObj()\s\s\ncan\sand\sdoes\sfree\sthem\sto\sconvert\sobjPtr\sinto\sbytecode.\s\s\nThe\sfollowing\sscript\sshould\sreproduce\sthe\sproblem\s\n(under\sLinux\sat\sleast).\s\n\s\n########################################\s\n#\sSTART\sOF\sFILE\s\n#\sSave\sas\sa\sfile\sand\sexecute\s"tclsh\sFILE"\sto\ssee\scrash\s\n\sif\s{![info\sexists\sSRC]}\s{\s\n\s\sset\sSRC\s[list\ssource\s$argv0]\s\n\s\suplevel\s#0\s$SRC\s\n}\selse\s{\s\n\s\snamespace\seval\sx\s{\s\n\s\s\s\sif\s{[info\sexists\s::DONE]}\s{\serror\s"DUPLICATE\sSOURCE"\s}\s\n\s\s\s\sset\s::DONE\s1\s\n\s\s\s\snamespace\seval\s::\s$SRC\s\n\s\s}\s\n}\s\n#\sEND\sOF\sFILE\s\n#####################################\s\n\s\n\s\nI've\sfound\stwo\sspecific\schanges\sthat\seliminate\sthe\ssegfault\sproblem\s\nfor\sme\s(although\sthis\sis\sby\sno\smeans\sa\scomprehensive\ssolution).\s\n\s\nThe\sfirst\sis\sin\sTcl_FSEvalFile()\swhere\sthe\sfollowing\sblock\sis\smoved\safter\s\nthe\serror\sprocessing\s(to\sjust\sbefore\sthe\s"end:"\slabel).\s\n\s\n\s\n\s\s\s\sif\s(iPtr->scriptFile\s!=\sNULL)\s{\s\n\s\s\s\s\s\s\s\sTcl_DecrRefCount(iPtr->scriptFile);\s\n\s\s\s\s}\s\n\s\s\s\siPtr->scriptFile\s=\soldScriptFile;\s\n\s\n\s\nThe\ssecond\sis\sa\schange\sto\sthe\sTcl_EvalObjv\scall\sin\sTcl_EvalObjEx().\s\nThere\sare\stwo\spossibilities\shere.\s\sOption\s1\sis\sto\sjust\sadd\s\nTCL_EVAL_INVOKE\sto\s\s\nthe\sflag\sin\sthe\scall.\s\sie:\s\n\s\n\s\n\s\s\sresult\s=\sTcl_EvalObjv(interp,\slistRepPtr->elemCount,\s\n\s\s\s\s\s\s\s\s\slistRepPtr->elements,\sflags\s|\sTCL_EVAL_INVOKE);\s\n\s\n\s\nIf\sthat\sis\sundesirable,\sthen\soption\s2\sis\sa\snew\sTclEvalObjvList()\sfunction\s\nwhich\stakes\san\sadditional\sargument\s(the\slistRepPtr)\swhich\scan\sbe\s\nchecked\s\nto\ssee\sif\sthe\srepresentation\sis\sno\slonger\sa\slist,\sbefore\serror\sprocessing.\s\nTcl_EvalObjEx()\scan\suse\sthis\snew\sfunction.\s\neg.\s\n\s\n\s\nstatic\sint\s\nTclEvalObjvList(interp,\sobjc,\sobjv,\sflags,\sobjPtr)\s\n//\s\sOld\sbody\sof\sTcl_EvalObjv\shere...\s\n\s\s\s\sif\s((code\s==\sTCL_ERROR)\s&&\s!(flags\s&\sTCL_EVAL_INVOKE))\s{\s\n\s\n\s\n\s\s\s\s\s\s\s\s/*\s\s\n\s\s\s\s\s\s\s\s\s*\sIf\sthere\swas\san\serror,\sa\scommand\sstring\swill\sbe\sneeded\sfor\sthe\s\s\n\s\s\s\s\s\s\s\s\s*\serror\slog:\sgenerate\sit\snow\sif\sit\swas\snot\sdone\spreviously.\s\n\s\s\s\s\s\s\s\s\s*/\s\n\s\n\s\n\s\s\s\s\s\s\s\sif\s(cmdLen\s==\s0\s&&\s((!objPtr)\s||\s(objPtr->typePtr\s==\s\n&tclListType)))\s{\s\n//...\s\n}\s\n\s\n\s\nint\s\nTcl_EvalObjv(interp,\sobjc,\sobjv,\sflags)\s\n...\s\n{\s\n\s\s\sreturn\sTclEvalObjvList(interp,\sobjc,\sobjv,\sflags,\sNULL);\s\n}\s\n\s\n\s
J foundin None
J priority 5\sMedium
J resolution None
J status Open
J submitter pcmacdon
J subsystem 10.\sObjects
J title segfault\s
J type Bug
K 1119369fffffffffffffffffffffffffffffffff
U pcmacdon
Z 738522516362f3ccb661eddbd3ab53a3