Skip to content
Tcl Source Code Artifact [392a22a4e7]
Login

Artifact [392a22a4e7]

Artifact 392a22a4e780afb635dfef60a88396cb60363e6178ea7ceb07e95c2dec2db6d2:

Ticket change [392a22a4e7] - Ticket [578155d5a19b348d|578155d5a1] <i>Very rare bug (segfault) if set variable (with error case) using self-releasable object as new value</i> status still Open with 3 other changes by dgp on 2018-01-11 15:56:32.
D 2018-01-11T15:56:32.945
J icomment \r\nIf\syou\shaven't\salready\sseen\sit,\sthe\shistory\sof\sthe\r\npurpose\sof\sthe\sinterface\schange\sin\sTcl_ObjSetVar2()\r\nbetween\s8.4\sand\s8.5\sis\shere\r\n\r\nhttps://core.tcl.tk/tcl/tktview/1334947\r\n\r\nIt\swas\snot\suntil\smuch\slater\sthat\sthe\scorresponding\schange\r\nto\sTcl_SetVar2Ex()\swas\scompleted\sproperly.\r\n\r\nhttps://core.tcl.tk/tcl/tktview/7368d225a6\r\n\r\nIn\s8.4\sit\swas\simpossible\sto\scall\sthe\svariable\ssetting\r\nroutines\sin\sa\sway\sthat\scould\sfully\sreliably\sprevent\r\nmemory\sleaks.\sError\spaths\sfrom\sfailed\slookup\swere\r\ninconsistent\swith\serror\spaths\sfrom\straces.\r\nIt\swas\san\sunusable\sinterface.\r\n\r\nFor\s8.5,\sthe\srefcount\sbehavior\sof\sthe\svariable\ssetting\r\nroutines\swas\schanged\sto\swhat\sit\sis\snow.\s\sThese\sroutines\r\nnow\sact\sas\sConsumers\sof\sthe\s"newValuePtr"\sargument.\r\nEffectively\sthey\salways\sincr\sthe\srefCount,\sand\spromise\r\nto\seventually\sdecr\sit.\s\sIf\syou\spass\sin\sa\s0\sref\scount\snewly\r\ncreated\svalue,\sthis\sscheme\swill\snot\sleak\sit.\sThat's\sthe\r\nmost\sconvenient\sway\sto\suse\sthese\sroutines.\s\sIt\sis\spossible\r\nthe\snewValuePtr\swill\sbe\sfreed\sbefore\sthe\svariable\ssetting\r\nroutine\sreturns.\s\sIf\sthe\scaller\shas\sa\sneed\sto\suse\sthat\svalue\r\nafter\sthe\svariable\ssetting\sroutine\sreturns,\sit\sneeds\sto\r\nexplicitly\smake\sits\sown\sincr\sof\sthe\srefcount\sto\spreserve\r\nthe\svalue\sand\sits\sown\sbalancing\sdecr.\r\n\r\nIf\syou\sfind\scode\slike\sthis\sanywhere:\r\n\r\nTcl_Obj\s*newObj\s=\sTcl_NewObj();\r\nif\s(Tcl_ObjSetVar2(interp,\svarObj,\sNULL,\snewObj,\s0)\s==\sNULL)\s{\r\n\s\sTcl_DecrRefCount(newObj);\r\n\s\sreturn\sTCL_ERROR;\r\n}\r\n\r\nIt\sis\san\soutdated\sattempt\sto\scode\sto\sthe\s8.4\sinterface.\r\nIt\smust\sbe\schanged\sto\swork\sproperly\swith\sTcl\s8.5\sand\slater.\r\nSee\sfor\sexample,\r\n\r\nhttp://core.tcl.tk/tk/tktview?name=3607326\r\n\r\nI\sagree\sthe\sdocumentation\sof\sthis\sis\snot\sgood\senough.\sBut\r\nthat's\sthe\sonly\sbug\sI\ssee.\r\n\r\nIf\sI'm\smissing\ssome\sscenario\swhere\sthat's\snot\saddressing\ssomething\r\nimportant,\sI'm\safraid\sI'm\sgoing\sto\sneed\sa\sconcrete\sdemonstration\r\n(not\sa\sdescription.\sSomething\sI\scan\srun)\sto\ssee\sit.\s\sBest\sI\scan\stell\r\nonly\sa\smisbehaving\svariable\sresolver\scan\scause\strouble,\sand\sin\sthat\r\ncase\sthe\sremedy\swould\sbe\sto\smake\sthat\sresolver\sbehave.
J login dgp
J mimetype text/plain
K 578155d5a19b348dc1a9fe96cc2c067a59326a89
U dgp
Z 534e517add1eedc765c3331765ca1048