Skip to content
Tcl Source Code Artifact [a563168c47]
Login

Artifact [a563168c47]

Artifact a563168c4729c3e34d3fbee62417630460466012:

Ticket change [a563168c47] - Ticket [219393ffffffffff|219393ffff] <i>[trace] should use Tcl_Preserve()</i> status still Open with 4 other changes by dkf on 2001-03-23 18:44:41.
D 2001-03-23T18:44:41
J icomment Logged\sIn:\sYES\s\nuser_id=79902\n\nI've\sbeen\slooking\sat\sthis\sin\sa\sbit\smore\sdetail,\sand\sit\sseems\nthat\sthe\sproblem\sstems\sfrom\sthe\sfact\sthat\sthe\sstandard\sC\nstring\sreturned\sby\sany\svariable\strace\sfunction\shas\sto\sbe\nstatic\s(i.e.\snot\sdeallocated\sbefore\sit\shas\sa\schance\sto\sbe\ncopied\sinto\sa\ssuitable\serror\sstring\sfor\sthe\sinterpreter)\sand\nyet\serror\sresults\sspat\sout\sby\straces\sare\snot\sat\sall\nguaranteed\sto\sbe\sstatic.\sCurrently,\sthe\swork-around\sfor\sthis\ninvolves\sstoring\sa\spointer\sto\sa\scopy\sof\sthe\serror\sstring\sin\nthe\strace\sstructure\sitself,\sbut\sthis\sis\sobviously\nsusceptable\sto\sthe\ssorts\sof\sproblems\sdescribed\sin\sthis\sbug.\s\nCommand\straces\sdo\snot\shave\sthis\sproblem\sat\sall.\n\nThere\sare\sthree\spossible\sworkarounds:\n\s\s1)\sUse\sTcl_Preserve()\sand\sTcl_Release()\sto\skeep\shold\sof\nthe\sstructure;\sthe\sonly\sproblem\swith\sthis\sis\sthat\sto\skeep\nthe\sinterface\sstatic,\sthese\soperations\shave\sto\sbe\sapplied\sin\ntclVar.c:CallTraces\s(i.e.\sapplied\sto\sthe\sclientData\sprior\sto\ncalling\sthe\strace\sitself)\sin\sorder\sto\sensure\sthat\sthere\sis\nsufficient\sguaranteed\stime\sfor\sa\stemporary\sstring\sto\sbe\nallocated\sto\skeep\sa\scopy\sof\sthe\sstring\sbefore\sit\svanishes.\nThis\sis\snasty,\sand\srequires\sa\sdoc\supdate\sto\smention\sthis\nnon-obvious\sbehaviour\s(which\scould\stheoretically\scause\sall\nsorts\sof\stroubles...)\n\s\s2)\sIntroduce\san\sextra\sflag\sto\sbe\spassed\sto\sTcl_TraceVar\n(and\sfriends)\sto\sindicate\sthat\snon-NULL\sresults\sreturned\sby\nthe\scallback\sare\sactually\sdynamic\sstrings\sthat\sneed\sto\sbe\nreleased\swith\sckfree()/Tcl_Free()\swhen\sfinished\swith.\n\s\s3)\sIntroduce\san\sextra\sflag\sto\sbe\spassed\sto\sTcl_TraceVar\n(and\sfriends)\sto\sindicate\sthat\snon-NULL\sresults\sreturned\sby\nthe\scallback\sare\sactually\spointers\sto\sTcl_Objs\s(cast\sto\nchar*)\sthat\scontain\sthe\serror\smessage,\sand\scan\sbe\shandled\sby\nthe\susual\slifetime\smanagement\smechanisms.\n\nSolutions\s2)\sand\s3)\scan\scoexist\swith\seach\sother\sand\swill\snot\ncause\sany\sbackward\sincompatabilities,\sbut\swill\sneed\sa\sshort\nTIP\sto\sintroduce.\s\sBut\sI\ssuppose\sthat's\strue\sof\s1)\sas\swell,\nand\sthat's\san\salternative\sI\sdon't\slike\s(it\scauses\nnon-trivial\sleakage\sof\sbehaviour\sthat\scould\scause\sproblems\nfor\sextension\swriters.)\n
J login dkf
J mimetype text/plain
J username dkf
K 219393ffffffffffffffffffffffffffffffffff
U dkf
Z c8bc126e95a9e3e1deed93af0b721e8b