Tcl Source Code

Artifact [41b5007729]
Login

Artifact 41b5007729124f8be969dd0e3bbb85dc9e2d14e3:

Ticket change [41b5007729] - New ticket [da15321a58] crash in variable traces when using itcl. by anonymous 2013-12-02 10:18:35.
D 2013-12-02T10:18:35.125
J assignee nobody
J closer nobody
J cmimetype text/plain
J comment Tcl/Tk\s8.5.15\son\sLinux\sand\sWindows\r\nItcl\s3.4\r\n\r\nThe\sappended\scode\scrashes\sTCL\s(sometimes\simmediately,\ssometimes\safter\r\none\sminute):\r\n\r\n(gdb)\swhere\r\n#0\s\s0xb745fe7a\sin\sTcl_GetString\s()\sfrom\s/aegis/si++/branch.4/branch.0/baseline/lib/linux/libtcl8.5.so\r\n#1\s\s0xb75060dc\sin\sButtonTextVarProc\s()\sfrom\s/aegis/si++/branch.4/branch.0/baseline/lib/linux/libtk8.5.so\r\n#2\s\s0xb74826b7\sin\sTclCallVarTraces\s()\sfrom\s/aegis/si++/branch.4/branch.0/baseline/lib/linux/libtcl8.5.so\r\n#3\s\s0xb7482bd7\sin\sTclObjCallVarTraces\s()\sfrom\s/aegis/si++/branch.4/branch.0/baseline/lib/linux/libtcl8.5.so\r\n#4\s\s0xb748b061\sin\sTclPtrSetVar\s()\sfrom\s/aegis/si++/branch.4/branch.0/baseline/lib/linux/libtcl8.5.so\r\n#5\s\s0xb7425644\sin\sTclExecuteByteCode\s()\sfrom\s/aegis/si++/branch.4/branch.0/baseline/lib/linux/libtcl8.5.so\r\n#6\s\s0xb742f491\sin\sTclCompEvalObj\s()\sfrom\s/aegis/si++/branch.4/branch.0/baseline/lib/linux/libtcl8.5.so\r\n#7\s\s0xb73df911\sin\sTclEvalObjEx\s()\sfrom\s/aegis/si++/branch.4/branch.0/baseline/lib/linux/libtcl8.5.so\r\n#8\s\s0xb73dfdab\sin\sTcl_EvalObjEx\s()\sfrom\s/aegis/si++/branch.4/branch.0/baseline/lib/linux/libtcl8.5.so\r\n#9\s\s0xb6e233c1\sin\sItcl_EvalMemberCode\s()\sfrom\s/aegis/si++/branch.4/branch.0/baseline/tcltk/linux/lib/itcl3.4/libitcl3.4.so\r\n\r\nwhen\sdereferencing\sa\sNULL-Pointer\sin\sTcl_GetString().\r\n\r\nThe\scause\sof\sthe\scrash\sis\sa\sstale\sTk-Button\spointer\sin\sthe\slist\sof\r\nvariable\straces,\swhich\slater\sis\sreferenced\swhen\sno\s-textvariable\sis\r\nbound\sto\sthe\sbutton.\r\n\r\nAs\sfas\sas\sI\scan\stell,\sthe\sfollowing\shappens:\r\n\r\n-\sa\sbutton\sis\screated\sand\scoupled\svia\s-textvariable\sto\sa\svariable\r\n\s\sin\sa\sdifferent\sitcl\sobject\r\n-\sdue\sto\sthe\s-textvariable\sbutton\sand\svariable\sare\sentered\sin\sthe\r\n\s\stracelist\sof\sthat\svariable\r\n-\sthat\svariable\sis\sdestroyed\swhen\sthe\sitcl\sobject\sis\sdestroyed,\sthe\r\n\s\svariable\strace\striggers\sand\sre-establishes\sthe\svariable\ssince\sit\r\n\s\sstill\sis\scoupled\sto\sthe\sbutton\s(tkButton.c,\sButtonTextVarProc())\r\n\s\s\s\s\s/*\r\n\s\s\s\s\s*\sIf\sthe\svariable\sis\sunset,\sthen\simmediately\srecreate\sit\sunless\sthe\swhole\r\n\s\s\s\s\s*\sinterpreter\sis\sgoing\saway.\r\n\s\s\s\s\s*/\r\n\s\s\r\n-\slater\sthe\sbutton\sis\sdestroyed\sand\stries\sto\suntrace\sthe\svariable,\r\n\s\s(tkButton.c,\sDestroyButton())\r\n\s\s\s\s\sif\s(butPtr->textVarNamePtr\s!=\sNULL)\s{\r\n\tTcl_UntraceVar(butPtr->interp,\sTcl_GetString(butPtr->textVarNamePtr),\r\n\t\tTCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,\r\n\t\tButtonTextVarProc,\s(ClientData)\sbutPtr);\r\n\s\s\s\s\s}\r\n\s\r\n\s\sbut\sfor\ssome\sreason\sI\sdon't\sunderstand\syet,\sTcl_UntraceVar()\sdoes\r\n\s\snot\sfind\sthe\svariable\sand\sjust\sreturns,\sleaving\sthe\sstale\sbutton\r\n\s\spointer\sin\sthe\sglobal\strace\slist.\r\n\r\n-\snow\sButtons\sand\sVariables\sget\srecreated,\sand\sthe\spointers\sare\r\n\s\seventually\sreused.\s\sNow\sit\scan\shappen\sthat\sa\sbutton\swithout\r\n\s\s-textvariable\sis\sassigned\sthe\s(stale)\spointer\sin\sthe\strace\slist,\sand\r\n\s\sa\svariable\scoupled\sto\sa\sdifferent\sbutton\sis\sassigned\sthe\svariable\r\n\s\spointer\swhich\sleads\sto\sthe\sstale\sbutton\spointer.\s\sWhen\sthe\straces\r\n\s\sfor\sthat\svariable\sare\sexecuted,\sthe\sstale\sbutton\spointer\s(which\sin\r\n\s\sthe\smeantime\sis\sa\svalid\sbutton\sagain,\sbut\swithout\s-textvariable)\sis\r\n\s\spassed\sto\sButtonTextVarProc(),\swhich\stries\sto\sget\sthe\s-textvariable\r\n\s\sand\scrashes.\r\n\r\n\r\nHere\sis\sthe\scode,\smaybe\ssomeone\swith\sdeeper\sinsight\scan\sfind\swhy\sthe\r\nbutton\sdoes\snot\sfind\sthe\svariable\swhen\sthe\sbutton\sis\sdestroyed.\r\nIt\sdefinetly\sis\srelated\sto\sitcl\s(couldn't\sreproduce\sit\susing\sordinary\r\nnamespaces)\sand\sthe\sway\sitcl\svariables\sare\snamed\swhen\susing\r\n[itcl::scope]\sand\sin\sthe\sobjects\sthemselves.\r\n\r\nThe\scode\screates\s4\sbuttons\sin\sone\sitcl\sobject\sand\sround-robin\scouples\r\nthem\sto\stextvariables\sin\sa\sdifferent\sitcl\sobject.\s\sThe\sbuttons\sand\r\nobjects\sare\sdestroyed\sand\sre-created\susing\sthe\sevent\sloop,\sso\ssooner\sor\r\nlater\sthe\scombination\sof\spointers\sdescribed\sabove\striggers.\r\n\r\n\r\n#\s==============================\r\n\r\npackage\srequire\sItk\r\n\r\nitcl::class\sbar\s{\r\n\s\s\s\spublic\s{\r\n\tmethod\sconfig_textvar\s{w\svar}\s{\r\n\t\s\s\s\s$w\sconfigure\s-textvariable\s[itcl::scope\s$var]\r\n\t\s\s\s\sset\s$var\s[clock\sseconds]\r\n\t}\r\n\s\s\s\s}\r\n\s\s\s\sprivate\s{\r\n\tvariable\sfoo\s0\r\n\tvariable\sbar\s0\r\n\s\s\s\s}\s\s\s\s\r\n}\r\n\r\nitcl::class\sfoo\s{\r\n\s\s\s\sinherit\sitk::Widget\r\n\s\s\s\sconstructor\sargs\s{\r\n\tcreate\r\n\s\s\s\s}\r\n\r\n\s\s\s\spublic\s{\r\n\tmethod\screate\s{}\s{\r\n\t\s\s\s\sset\sobj_\s[uplevel\s\\#0\sbar\s\\#auto]\r\n\t\s\s\s\spack\s[frame\s$itk_interior.f]\s-fill\sboth\s-expand\syes\r\n\t\s\s\s\spack\s[button\s$itk_interior.f.a]\s[button\s$itk_interior.f.b]\s[button\s$itk_interior.f.c]\s[button\s$itk_interior.f.d]\s-fill\sboth\s-expand\syes\r\n\t\s\s\s\sswitch\s--\s$count_\s{\r\n\t\t0\s{\r\n\t\t\s\s\s\s$obj_\sconfig_textvar\s$itk_interior.f.a\sfoo\r\n\t\t\s\s\s\s$itk_interior.f.b\sconfigure\s-textvariable\s[itcl::scope\scount_]\r\n\t\t}\r\n\t\t1\s{\r\n\t\t\s\s\s\s$obj_\sconfig_textvar\s$itk_interior.f.b\sfoo\r\n\t\t\s\s\s\s$itk_interior.f.c\sconfigure\s-textvariable\s[itcl::scope\scount_]\r\n\t\t}\r\n\t\t2\s{\r\n\t\t\s\s\s\s$obj_\sconfig_textvar\s$itk_interior.f.c\sfoo\r\n\t\t\s\s\s\s$itk_interior.f.a\sconfigure\s-textvariable\s[itcl::scope\scount_]\r\n\t\t}\r\n\t\s\s\s\s}\r\n\t\s\s\s\safter\s$interval_ms_\s[itcl::code\s$this\sassign]\r\n\t}\r\n\tmethod\sassign\s{}\s{\r\n\t\s\s\s\sincr\scount_\r\n\t\s\s\s\sif\s{$count_\s>\s2}\s{\sset\scount_\s0\s}\r\n\t\s\s\s\sset\sfoo_\s$count_\r\n\t\s\s\s\safter\s$interval_ms_\s[itcl::code\s$this\sremove]\r\n\t}\r\n\tmethod\sremove\s{}\s{\r\n\t\s\s\s\srename\s$obj_\s{}\r\n\t\s\s\s\sdestroy\s$itk_interior.f\r\n\t\s\s\s\sunset\sfoo_\r\n\t\s\s\s\safter\s$interval_ms_\s[itcl::code\s$this\screate]\r\n\t}\r\n\s\s\s\s}\r\n\s\s\s\sprivate\s{\r\n\tvariable\sinterval_ms_\s100\r\n\tvariable\scount_\s0\r\n\tvariable\sfoo_\s0\r\n\tvariable\sobj_\s{}\r\n\s\s\s\s}\r\n}\r\n\r\nwm\sgeometry\s.\s200x200\r\nupdate\sidle\r\npack\s[foo\s.foo]\s-fill\sboth\s-expand\syes\r\n\r\n#\sEnd\sof\sfile
J foundin 8.5.15
J is_private 0
J login anonymous
J priority 5\sMedium
J private_contact 1d3c95db24e116878d6afed7cf890a89a0effe62
J resolution None
J severity Important
J status Open
J submitter anonymous
J subsystem 46.\sTraces
J title crash\sin\svariable\straces\swhen\susing\sitcl
J type Bug
K da15321a5852265331fcf94de655365551b9fa90
U anonymous
Z 3813a0d60d79cef4e2ef63b2b997620e