.
D 2010-01-07T22:00:03
J assignee nobody
J cmimetype text/plain
J comment Tcl\sVersion:\s5.8.6\s(but\slikely\sin\s5.8.7\sas\swell)\nOs\sPlatform\sand\sVersion:\sWindows\s2003\sServer\n\nBefore\sloading\sthe\sTcl\slibrary,\sour\scalling\sprogram\sclosed\sSTDIN,\swhich\sit\sdoes\snot\sread.\sWhen\sthe\sTcl\slibrary\swas\sloaded,\sit\seventually\scalled\sTclpGetDefaultStdChannel()\sto\screate\sthe\sTcl\sSTDIN\schannel.\sThis\sin\sturn\seventually\scalled\sthe\sWindows\ssystem\sGetStdHandle()\sto\sget\sthe\sWindows\sSTDIN\sfile\sdescriptor.\n\nApparently,\seven\sthough\sSTDIN\shad\swas\sclosed,\sGetStdHandle()\sreturned\sa\snonzero\s(bogus)\sfile\sdescriptor,\spresumably\sthe\soriginal\sSTDIN\sfile\sdescriptor\sthat\shad\sbeen\sclosed.\sI\s\sdo\snot\sknow\sif\sthis\sis\sa\sGetStdHandle()\sbug\sor\sfeature,\snor\sdo\sI\sknow\sif\sit\sis\sspecific\sto\sWindows\sServer\s2003.\n\nSubsequent\sTcl\scode\sassumed\sthe\sbogus\sSTDIN\sfile\sdescriptor\swas\svalid\sand\screated\sits\sTcl\sSTDIN\schannel\son\sit.\sThe\sTcl\sSTDIN\schannel\swas\sgiven\sinterpreter\sreference\scount\srefCount\s=\s2\sinstead\sof\sthe\snormal\srefCount\s=\s1.\sI\spresume\sthis\sis\sdone\sto\sprevent\sa\sTcl\sinterpreter\sthread\sfrom\sclosing\sthe\scalling\sprogram's\sSTDIN.\sSo\snow\swe\shave\sa\sTcl\sSTDIN\schannel\swith\srefCount\s=\s2\son\sa\sbogus\sclosed\sSTDIN\sfile\sdescriptor.\n\nAfter\sloading\sthe\sthreaded\sTcl\slibrary,\sthe\scalling\sprogram\sthen\sproceeded\sto\sinterpret\sseveral\sTcl\sscripts.\sThis\sultimately\sended\sup\scalling\sTcl\sFSEvalFileEx()\sin\swin/tclIOUtil.c,\swhich,\sseveral\slayers\sdown,\scalls\sthe\sWindows\ssystem\sCreateFileA()\sor\sCreateFileW()\sto\sobtain\sa\sWindows\sfile\sdescriptor\sfor\sthe\sfile.\n\nHowever,\ssince\sSTDIN\sis\sclosed,\sWindows\seventually\srecycles\sthe\sSTDIN\sfile\sdescriptor,\sand\spossibly\safter\smany\scalls,\sCreateFileA()\sor\sCreateFileW()\sreturns\sthe\soriginal\sSTDIN\sfile\sdescriptor.\sWhen\sthis\shappens,\sTcl\sidentifies\sthe\sfile\sdescriptor\swith\sits\sbogus\sSTDIN\schannel\sand\sincrements\sthe\schannel's\srefCount\sto\s3,\sinstead\sof\screating\sa\snew\sfile\schannel\sas\sit\sshould.\sIt\sreads\sfrom\sits\sSTDIN\schannel,\swhich\ssucceeds\sbecause\sthe\sdefunct\sfile\sdescriptor\sis\snow\sopen\son\sthe\snew\sfile.\sFinally,\sTcl_FSEvalFileEx()\scalls\sTcl_Close()\son\sthe\sfile\sdescriptor\sto\sclose\sthe\sfile.\sThis\scauses\sTcl_Close()\sto\stry\sto\sclose\sthe\sSTDIN\schannel.\sIt\snotices\srefCount\s>\s0\son\sthe\schannel,\sdecides\sit\sis\sclosing\ssome\sother\sinterpreter's\schannel,\sand\saborts\swith\sthe\smessage\n\ncalled\sTcl_Close\son\schannel\swith\srefCount\s>\s0\n\ntaking\sthe\scalling\sprogram\swith\sit.\n\nWe\swere\sable\sto\swork\saround\sthis\sin\sour\scase\sby\sleaving\sSTDIN\sopen\son\sthe\scalling\sprogram.\n\n
J foundin obsolete:\s8.5.8
J is_private 0
J priority 5\sMedium
J resolution None
J status Open
J submitter mohanchous
J subsystem None
J title Tcl\sdies\swhen\sSTDIN\sis\sclosed
J type Bug
K 2927851fffffffffffffffffffffffffffffffff
U mohanchous
Z bb3218208c7c25124e049d888543d881