Skip to content
Tcl Source Code Artifact [61b15ff00c]
Login

Artifact [61b15ff00c]

Artifact 61b15ff00c4e4c84fa8fbb3499b3c26a3fe048c9:

Ticket change [61b15ff00c] - Ticket [2939073fffffffff|2939073fff] <i>IPC via sockets and traces causes segfault</i> status still Open with 4 other changes by ferrieux on 2010-02-01 08:33:40.
D 2010-02-01T08:33:40
J icomment Ha\s!\sGot\sit\snow.\n\nIn\struth\sthe\ssecondary\sunset\s_does_\skill\sthe\shash\sentry\sin\sthat\scase,\sit's\sjust\sthat\sthe\sreuse\sof\sthe\sfreed\sblock\sdoesn't\scause\simmediate\sharm\snormally.\sHence\sI\shad\sto\sadd\sthe\sfollowing\s'sanitizing'\sline\sto\sFreeVarEntry:\n\n\s\s\s\s\s\s\s\s\sif\s(TclIsVarUndefined(varPtr)\s&&\s!TclIsVarTraced(varPtr)\n\s\s\s\s\s&&\s(VarHashRefCount(varPtr)\s==\s1))\s{\n+varPtr->value.objPtr=(void\s*)0xdeadbeef;\n\sckfree((char\s*)\svarPtr);\n\nIt\sis\ssimply\sa\smatter\sof\sresetting\sa\sfield\sto\sa\svisibly\sinvalid\svalue\sjust\sbefore\sfreeing.\nThe\seffect\sis\sthat,\sas\ssoon\sas\ssomebody\sreuses\sthat\sfreed\sstructure\s(and\stypically\sby\sindirections\soff\sthis\sobjPtr\sfield),\sa\sSIGSEGV\sor\sSIGBUS\swill\sburst\son\s0xdeadbeef.\n\nAnd\sit\sdoes:\sgiven\sthis\ssanitizing\spatch,\sthe\sfollowing\sultrashort\sexample\scrashes\stclsh:\n\narray\sset\sx\s{e\s1\si\s1}\ntrace\sadd\svariable\sx\sunset\srem\nproc\srem\sargs\s{\n\s\s\s\sputs\sREM:$args\n\s\s\s\sif\s{![info\sexists\s::already]}\s{\nset\s::already\s1\nunset\s::x(e)\n\s\s\s\s}\n}\narray\sunset\sx\s*\n\nExplanation:\sa\snascent\sarray\swith\sa\ssmall\ssize\shas\sonly\s4\sbuckets,\sallowing\sa\squick\ssearch\sof\scollisions.\nIt\sturns\sout\s'e'\sand\s'i'\sfall\sin\sthe\ssame\sbucket.\sSince\sthe\sentries\sof\sa\ssame\sbucket\sare\sstored\sin\sa\sLIFO\slinked\slist,\sthe\s[array\sunset\sx\s*]\siteration\swill\sdo\s'i',\sthen\s'e'.\sThe\srest\sof\sthe\scode\sarranges\sfor\sthe\s'e'\sto\sbe\sremoved\sas\sa\sside\seffect\sof\sthe\sunset\strace\son\s'i',\shence\sremoving\sthe\srug.\sBoom.\n\nRenaming\sthe\sbug\saccording\sto\sthis\sconfirmation.\n
J login ferrieux
J mimetype text/plain
J username ferrieux
K 2939073fffffffffffffffffffffffffffffffff
U ferrieux
Z 5fe470cce65dcd664f5ec8e398d47488