Skip to content
Tcl Source Code Artifact [71126824be]
Login

Artifact [71126824be]

Artifact 71126824be9fcce60db82177871692507270387bc0198f75aa793eb7d750ee35:

Ticket change [71126824be] - New ticket [24949cbd7cb727c6|24949cbd7c] <i>Many functions of tclPathObj are not thread safe (can segfault by changing of FS epoch)</i>. by sebres on 2021-08-10 12:45:25.
D 2021-08-10T12:45:25.196
J assignee nobody
J closer nobody
J cmimetype text/x-fossil-wiki
J comment I\swas\ssearching\sfor\sthe\sheisenbug,\soccurring\sextremely\srare\sat\sinitialization\sphase\sof\sa\s(multithreaded)\stcl-application.\r\n\r\nThe\scallstack\sshows:\r\n<pre\sstyle="padding-left:10pt"><code>\r\nThread\s9\sreceived\ssignal\sSIGSEGV,\sSegmentation\sfault.\r\n[Switching\sto\sThread\s18320.0x1c0c]\r\n0x50589c0b\sin\stcl85!Tcl_GetStringFromObj\s()\sfrom\s./tcl85.dll\r\n(gdb)\sbt\r\n#0\s\s0x50589c0b\sin\stcl85!Tcl_GetStringFromObj\s()\sfrom\s./tcl85.dll\r\n#1\s\s0x505d9e87\sin\stcl85!TclpMatchInDirectory\s()\sfrom\s./tcl85.dll\r\n#2\s\s0x50575db6\sin\stcl85!Tcl_FSMatchInDirectory\s()\sfrom\s./tcl85.dll\r\n...\r\n#35\s0x505962fc\sin\stcl85!Tcl_PkgRequireEx\s()\sfrom\s./tcl85.dll\r\n</code></pre>\r\n\r\nAfter\sanalyzing\sthe\scode\sin\sTclpMatchInDirectory\sand\stclPathObj,\sthe\serror\sis\sobvious\s-\sit\sis\soccurred\sby\s[./file?ci=1b84e484da461b64&name=win%2FtclWinFile.c&ln=981-1007|win/tclWinFile.c&ln=981-1007]\sin\sln.\s1007\swhen\sbetween\sln.\s981\sand\sln.\s990\ssome\sother\sthread\schanging\sthe\sFS\sepoch,\sso\sthe\sobject\s<code>pathPtr</code>\sinvalidates\sthe\sinternal\srepresentation\sand\s<code>fileNamePtr</code>\sdisappears.<br/>\r\n(Indirectly,\sthis\sgoing\sto\sthe\s[./file?ci=1b84e484da461b64&name=generic/tclPathObj.c&ln=1175|Tcl_FSConvertToPathType]\swhich\scan\sinvalidate\sthe\sobject\sif\scheck\swith\sTclFSEpochOk\sshows\smodification\sof\sFS\sepoch,\swhich\sis\ssystem\swide\sso\scan\soccur\sin\sother\sthread).\r\n\r\nOne\scould\ssurely\sincrement\sthe\sreference\sof\s<code>fileNamePtr</code>\sin\sTclpMatchInDirectory\stemporarily,\sbut\sthere\sare\stoo\smany\scode\spieces\s(inclusive\stclPathObj.c\sitself)\swith\sthe\sassumption\sthat\sif\spath-object\scan't\sshimmer,\sits\sinternal\srepresentation\sremains\sthe\ssame,\swhat\sis\sobviously\snot\sthe\scase\sby\sthis\sapproach\sconsidering\sthe\ssystem\swide\sepoch.\r\n\r\nIf\sthis\sissue\scannot\sbe\ssolved\susing\sdifferent\scommon\sapproach,\sthe\swhole\scode\susing\sseveral\spath-API\sfunctions\s(in\sgeneric/\sbut\salso\sin\swin/\sand\sunix/)\smust\sbe\sreviewed,\se.\sg.\sextended\swith\sincr+decr\sref-count\sfor\smany\sobjects\scomming\sfrom\sinternal\srepresentation\sof\spath-type\sobjects\susing\sTcl-API\sor\sdirect\sassignment.
J foundin >=\s8.5
J is_private 0
J login sebres
J priority 5\sMedium
J resolution None
J severity Critical
J status Open
J submitter sebres
J subsystem 36.\sPathname\sManagement
J title Many\sfunctions\sof\stclPathObj\sare\snot\sthread\ssafe\s(can\ssegfault\sby\schanging\sof\sFS\sepoch)
J type Bug
K 24949cbd7cb727c6ce8927ad6a7da6efe0d8ec59
U sebres
Z 9429d2e5a3d2f278900f30563fbcb2ed