Skip to content
Tcl Source Code Artifact [7e07975e64]
Login

Artifact [7e07975e64]

Artifact 7e07975e6438f6b7bdeb3699efbc786e2b7dfbff4c1838b1eeafcc9069de8e7e:

Ticket change [7e07975e64] - New ticket [70944d8f141bfe84|70944d8f14] <i>invalid refcount for classes in itcl?</i>. by ivk on 2020-09-28 13:28:16.
D 2020-09-28T13:28:16.673
J assignee nobody
J closer nobody
J cmimetype text/plain
J comment We\shave\smultiple\sTCL\sinterpreters\srunning\sin\sdifferent\sthreads.\sWe\sare\ssuffering\sfrom\sa\scrash\sthat\sseems\sto\sbe\scaused\sby\sthe\saccess\sto\sthe\salready\sdeleted\sItclClass.\sLong\sstory\sshort,\sitcl\stries\sto\sdelete\sthe\ssame\sclass\stwice\s-\swhen\sanother\sthread\sinterferes,\sit\scan\sallocate\sa\snew\sclass\sat\sthe\ssame\saddress\soverriding\sthe\sITCL_CLASS_IS_FREED\sflag\swhich\sleads\sto\sa\scrash\swhen\sitcl\saccess\sthis\sobject\sfor\sthe\ssecond\stime.\r\nConsider\sthe\sfollowing\ssnippet\s(crash.tcl):\r\n\r\npackage\srequire\sIwidgets\r\niwidgets::Labeledwidget\s\s.l\r\npack\s.l\r\nafter\s1000\r\nexit\r\n\r\nI\sran\sit\slike\sthis\s(using\sthe\sself-built\sinterpreter\sto\sremove\sour\smulti-threaded\senvironment\sfrom\sinvestigation):\s\r\nTCL_FINALIZE_ON_EXIT=1\stclsh8.6\s~/scripts/crash.tcl\r\n\r\nI've\salso\sadded\ssome\slogging\sto\sItclReleaseClass():\r\n\r\nif\s(iclsPtr->refCount--\s<=\s1)\s{\r\n\s\s\s\spthread_t\sid\s=\spthread_self();\r\n\s\s\s\sfprintf(stderr,\s"\s\s\s\sItclReleaseClass:\s%p,\srefCount:\s%d,\sthread:\s%lu\\n",\siclsPtr,\siclsPtr->refCount,\sid);\r\n\s\s\s\sItclFreeClass((char\s*)\sclientData);\r\n}\r\n\r\nNow,\sin\sthe\slogs\sI\ssee:\r\n\s\s\s\sItclReleaseClass:\s0x6290004dba10,\srefCount:\s0,\sthread:\s140564963183552\r\n\s\s\s\sItclReleaseClass:\s0x6290004dba10,\srefCount:\s-1,\sthread:\s140564963183552\r\n\r\nThis\srefcount\s-1\slooks\svery\ssuspicious\smeaning\sthat\sclass\shas\salready\sbeen\sfreed.\sIn\sa\ssingle-threaded\senvironment\sthere\sare\sno\s(re)allocations\sat\sthis\spoint\sof\stime\s=>\sflags\sare\snot\soverwritten\s=>\sthe\scode\sworks.\sHowever,\sit\sdoesn't\sseem\sright\sto\saccess\sthe\sfreed\smemory\s(without\sthe\scustom\sallocator,\sthat\swould\sbe\sa\ssigsegv,\sbut\sTCL\sallocator\shelps\shere\spreventing\ssegmentation\sviolation).
J is_private 0
J login ivk
J priority 5\sMedium
J resolution None
J severity Minor
J status Open
J submitter ivk
J subsystem 69.\sOther
J title invalid\srefcount\sfor\sclasses\sin\sitcl?
J type Bug
K 70944d8f141bfe849c6bd37ded7ce04ce8e27052
U ivk
Z a6e78f22ea1c428acc9319be250665a0