Skip to content
Tcl Source Code Artifact [bca3d8734a]
Login

Artifact [bca3d8734a]

Artifact bca3d8734a54d003664955791e1a1f9690996d46:

Ticket change [bca3d8734a] - New ticket [1440723fffffffff|1440723fff] <i> using time operation in tcl is unsafe in multithread app</i>. by tatooguy on 2006-03-01 03:17:08.
D 2006-03-01T03:17:08
J assignee nobody
J cmimetype text/plain
J comment VERSION:\s\n\s\sTcl8.3.2\nOS\sPlafform:and\sVersion:\n\s\sSunOS\swapgw1\s5.8\sGeneric_117350-22\ssun4u\ssparc\sSUNW,\s\n\nBrief\sDescription\sabout\sbehavior:\n\n\s\s\sI\shave\sa\smultithread\sprogram\sin\sunix\sc++\s.\sIn\sone\s\nthread,\sI\screate\sa\sTCl\sInterpreter\swith\s\nTcl_CreateInterp\sand\sexecute\sthe\sscript\sbuffer.\s\n\nIn\ssome\sother\sthreads\sI\sdo\ssome\sother\sthings.\n\n\s\s\sCurrently,\sI\smigrate\smy\sprogram\sfrom\smy\ssolaris\s8\s\nto\sanother\ssolaris\s8,\s\n\nit\soften\score\sdump\sabnormally\sif\sI\skeep\son\sexecute\sthe\s\nfollowing\stwo\stcl\ssencenses.\n\n\s\n\nset\ssystemTime\s[clock\sseconds];\n\nset\sTclVarTimeStamp\s[clock\sformat\s$systemTime\s-format\s%\nY-%m-%dT%H:%M:%SZ];\n\n\s\n\n\s\sI\scheck\sthe\ssource\scode\sand\sfind\sthat\sthere\sare\smany\s\nfunctions\srelated\sto\stime\sor\stime\szone\swhich\scall\s\nfunction\slocaltime()\n\nnot\slocaltime_r().\sAlthough\sI\sfind\smany\smutex\slock\sin\s\nthese\sfunctions,\sbut\sit\scan\sonly\sassure\sthat\sall\sthe\s\nTCLInterpreter\srelated\n\nthreads\scan\ssafely\scall\sthis\stype\sof\sfunction,\snot\s\nother\sthreads.\n\n\s\n\n\s\sFor\sexample:\sa\stwo\sthread\sapp\n\n\s\sThread1:\sTCLInterpreter\scall\slocaltime\swith\smutex\s\nlock\n\n\s\sThread2:\ssome\stimes\scall\slocaltime_r\n\n\s\sthen,\sno\smatter\show\sthe\sthread1’s\stcl\ssource\scode\s\nlock\sthe\slocaltime()\soperation,\s\s\sthread2\scan\salso\s\naccess\sthe\slocaltime_r()\n\n\s\ssince\sthe\stcl’s\smutex\slock\shave\snothing\sto\sdo\swith\s\nthread2,\sit\sonly\stake\seffect\sin\stcl8.3.2\ssource\scode.\s\nAnd\swhen\sthread1\sand\sthread2\n\n\s\scall\sthis\sfunction\sat\sthe\ssame\stime,\sit\swill\sbe\s\nunsafe!!!!\n\n\s\n\nSo,\sI\swonder\swhether\sthe\stcl8.3.2\srelated\stime\s\noperation\sis\sthread-safe\sand\show\sto\smake\sit\sthread-\nsafe.\sIn\sthe\slasted\sversion\stcl8.4.12,\n\nI\sstill\sfind\smany\splace\swhich\scall\slocaltime()\sinstead\s\nof\slocaltime_r().\n\n\s\n\nOne\smore\spuzzling\sthing\swhich\sI\scan’t\sfigure\sout\sand\s\nalso\sintersting:\n\n\s\sMy\sprogram\swas\sbuild\sin\sthe\sSolaris\sOS\swhose\ssystem\s\nTIMEZONE\sis\sPRC,\swhile\sthe\sSolaris\sOS\swhich\smake\smy\s\nprogram\score\n\nis\snot\sPRC\sbut\sothers\slike\sHongkong,\setc.\sIf\sI\sset\sthe\s\nTZ\senvironment\sin\sthe\sunix\slogin\sshell\sand\srun\smy\s\nprogram\sin\sthe\s“core”\sOS,\sit\sruning\sfine.\s\n\n\s\n\nWhy???\sanyone\smet\sthis\sbefore\sand\show\sto\sfix\sit?\s\nPersonly,\sI\sthink\sthe\stcl’s\stime\soperation\sis\sunsafe:\n(\sDoes\sit\sa\sknown\sbug?\s\n\n
J foundin None
J priority 5\sMedium
J resolution None
J status Open
J submitter tatooguy
J subsystem None
J title \susing\stime\soperation\sin\stcl\sis\sunsafe\sin\smultithread\sapp
J type Bug
K 1440723fffffffffffffffffffffffffffffffff
U tatooguy
Z 65b74a02a09e13c732a761ce31d97da5