Skip to content
Tcl Source Code Artifact [9a1925bb2a]
Login

Artifact [9a1925bb2a]

Artifact 9a1925bb2a2b1519161aefcfab88a60d26786471:

Ticket change [9a1925bb2a] - New ticket [943274ffffffffff|943274ffff] <i>Tcl 8.4.5 with Expect 5.39 hangs waiting for data matching p</i>. by mellenbe on 2004-04-27 19:48:55.
D 2004-04-27T19:48:55
J assignee andreas_kupries
J cmimetype text/plain
J comment See\sthe\sthread\sby\sthe\ssame\sname\sat\scomp.lang.tcl\sfor\s\nmore\sinformation.\n\nRunning\sthis\son\ssolaris.\s\sWe\shave\sa\slarge\stesting\s\nframework\swritten\sin\stcl/expect.\s\sThe\sframework\s\nexecutes\son\sone\splatform\s(solaris)\sand\suses\sspawn\sto\s\nstart\srsh\son\sanother\splatform.\s\sThe\sshell\sis\sleft\srunning\s\nfor\sthe\slife\sof\sa\stest\srun\swhich\scan\slast\sseveral\sdays.\n\nCommands\sare\ssent\sto\sthe\srsh\sshell\sand\sexpect\sis\sused\s\nto\sparse\sthe\sinput\sas\sit\sis\sreturned.\s\sWe\srecently\s\nupgraded\sto\smore\scurrent\sversions\sof\stcl\s8.4.5\sand\s\nexpect\s5.39\s(from\stcl\s7.5\sand\sexpect\s5.21).\n\nWhat\sI\shave\sfound\sis\swhen\sthe\srsh\sshell\sreturns\slarge\s\namounts\sof\sdata\s(approx\s150,000\sbytes)\sit\sis\svery\slikely\s\nto\sproduce\sa\shang.\n\nBack\strace\scopied\sfrom\scomp.lang.tcl,\n\n#0\s\s0xff21da28\sin\s_read\s()\sfrom\s/usr/lib/libc.so.1\n#1\s\s0x000284c8\sin\sExpInputProc\s\n(instanceData=0x176078,\n\s\s\s\sbuf=0x1784f0\s"rver\\r\\n137.69.53.234\\tpv2-\nmv\\r\\n137.69.51.200\\tpacket\\r\\n137.69.3.186\n\\tmarvel\\r\\n137.69.12.162\\tcal162\\r\\n137.69.9.235\n\\tbutiki\\r\\n137.69.5.45\\tableix\\r\\n137.69.121.160\n\\tbelem\\r\\n137.69.101.155\\tubik\\r\\n137.69.103.118\n\\trunt\\r\\n13"...,\ntoRead=4096,\serrorCodePtr=0xffbfe260)\sat\s\nexp_chan.c:122\n#2\s\s0x000b1148\sin\sGetInput\s(chanPtr=0x173a48)\sat\n./../generic/tclIO.c:5303\n#3\s\s0x000afb98\sin\sDoReadChars\s(chanPtr=0x173a48,\s\nobjPtr=0x164b88,\ntoRead=2092,\n\s\s\s\sappendFlag=1)\sat\s./../generic/tclIO.c:4447\n#4\s\s0x000af92c\sin\sTcl_ReadChars\s(chan=0x173a48,\s\nobjPtr=0x164b88,\ntoRead=4000,\n\s\s\s\sappendFlag=1)\sat\s./../generic/tclIO.c:4339\n#5\s\s0x000363d8\sin\sexpIRead\s(interp=0x15ba80,\s\nesPtr=0x176078,\ntimeout=10,\n\s\s\s\ssave_flags=0)\sat\sexpect.c:1652\n#6\s\s0x000364b0\sin\sexpRead\s(interp=0x15ba80,\s\nesPtrs=0x172f80,\nesPtrsMax=1,\n\s\s\s\sesPtrOut=0xffbfe580,\stimeout=10,\skey=12317)\sat\s\nexpect.c:1723\n#7\s\s0x000383d4\sin\sExp_ExpectObjCmd\s(clientData=0x0,\s\ninterp=0x15ba80,\nobjc=13,\n\s\s\s\sobjv=0xffbfe9a8)\sat\sexpect.c:2526\n#8\s\s0x00046d18\sin\sTclEvalObjvInternal\s\n(interp=0x15ba80,\sobjc=13,\n\s\s\s\sobjv=0xffbfe9a8,\scommand=0x12d3a8\s"",\slength=0,\s\nflags=0)\n\s\s\s\sat\s./../generic/tclBasic.c:3087\n#9\s\s0x00047058\sin\sTcl_EvalObjv\s(interp=0x15ba80,\s\nobjc=13,\nobjv=0xffbfe9a8,\n\s\s\s\sflags=0)\sat\s./../generic/tclBasic.c:3203\n#10\s0x000332a4\sin\sexp_eval_with_one_arg\s\n(clientData=0x0,\ninterp=0x15ba80,\n\n(gdb)\sp\s*esPtr\n$7\s=\s{channel\s=\s0x173a48,\sname\s=\s"exp4",\s'\\0'\s<repeats\s\n36\stimes>,\sfdin\n=\s4,\n\s\sfdout\s=\s4,\schannel_orig\s=\s0x0,\sfd_slave\s=\s-1,\s\nvalidMask\s=\s14,\spid\s=\n29846,\n\s\sbuffer\s=\s0x164b88,\smsize\s=\s4001,\sumsize\s=\s2000,\s\nprinted\s=\s4,\sechoed\n=\s0,\n\s\srm_nulls\s=\s1,\sopen\s=\s1,\suser_waited\s=\s0,\ssys_waited\s=\s\n0,\sregistered\n=\s1,\n\s\swait\s=\s0,\sparity\s=\s1,\skey\s=\s12317,\sforce_read\s=\s1,\s\nnotified\s=\s0,\n\s\snotifiedMask\s=\s2,\sfg_armed\s=\s0,\sleaveopen\s=\s0,\s\nbg_interp\s=\s0x0,\n\s\sbg_ecount\s=\s0,\sbg_status\s=\sunarmed,\s\nfreeWhenBgHandlerUnblocked\s=\s0,\n\s\sfdBusy\s=\s0,\skeepForever\s=\s0,\svalid\s=\s1,\snextPtr\s=\s\n0x170b50}\n(gdb)\sp\stoRead\n$8\s=\s4096\n(gdb)\sp\sbytesRead\n$9\s=\s0\n\nOur\sscript\slooks\slike\sthis,\sI\sadded\seof\sand\sfull_buffer\sto\s\nsee\sif\seither\swould\sget\sexecuted.\s\sThey\sdon't.\n\n\swhile\s{1}\s\s{\n\s\s\s\sexpect\s{\n\s\s\s\s\s\s\s\s-i\s$ID\s-re\s"(\\[^\\r]*)(\\r\\r\\n|\\r\\n)"\s{\n\s\s\s\s\s\s\s\sappend\slines\s"$expect_out(1,string)\\n"\n\s\s\s\s\s\s\s\scontinue\n\s\s\s\s\s}\n\s\s\s\s\s"$user_prompt"\s{\n\s\s\s\s\s\s\s\s\sputs\s"prompt"\n\s\s\s\s\s\s\s\s\sbreak\n\s\s\s\s\s}\n\s\s\s\s\seof\s{\n\s\s\s\s\s\s\s\sputs\s"\\n\s>>>\shit\seof"\n\s\s\s\s\s}\n\n\s\s\s\s\sfull_buffer\s{\n\s\s\s\s\s\s\s\sputs\s"\\n\sfull\sbuffer\shit"\n\s\s\s\s\s\s\s\sexit\s-1\n\s\s\s\s\s}\n\s\s}\n\nThe\sproblem\sis\sa\smix\sof\sbuffering\sand\sblocking\sIO.\s\sSince\s\nthe\srsh\sis\sa\slong\srunning\sserver,\swe\snever\ssee\san\sEOF\s\nfrom\sit.\s\sThe\suser_prompt\sis\sbasically\sa\slogical\seof\swe\s\nuse\sas\s"end\sof\sdata".\s\s\n\nWhat\sI\shave\sseen\sis\sall\sdata,\sincluding\sthe\slogical\seof\s\nhas\sbeen\sbuffered.\s\sThere\sis\sno\smore\sto\sexpect\sfrom\sthe\s\nrsh.\s\sDuring\sour\slast\strip\sthrough\sexpect/tcl\sa\sportion\sof\s\nthe\sdata\swas\sreturned\sbut\ssome\sdata\swould\snot\sfit\sin\s\nour\sbuffer\s(expect_out,\sI\sthink)\sso\sthe\sremainder\sis\sleft\s\nin\sthe\stcl\sbuffers.\s\s\n\nThe\snext\stime\swe\sgo\sthrough\sexpect/tcl\sthe\sremainder\s\nof\sthe\sdata\sis\sreturned\s(including\sour\slogical\seof)\sbut\s\nthen\sthe\slogic\sin\sDoReadChars\sdoes\sanother\sread.\s\sThe\s\nread\sis\sblocking\sand\swe\ssit\sthere\sforever.\n\nThere\sis\sa\stricky\sexchange\sthat\sneeds\sto\shappen\shere.\s\s\nI\sdon't\sknow\sif\sit\sis\sa\sproblem\swith\sexpect\sor\stcl\sor\sboth.\n\nIn\sour\scase,\swhen\sexpect\sis\sreading,\sblocking\sreads\s\nshouldn't\sbe\sissued\sunless\sthe\spattern\smatching\slogic\s\nhas\shad\sa\schance\sto\slook\sat\sthe\sdata\sand\sdecided\sto\s\ndrive\sanother\sread.\s\sIn\sthis\scase,\s\sthe\slogic\sin\s\nDoReadChars\scopies\sdata\sto\sthe\sexpect\sbuffer\sand\sthen,\s\nwithout\sletting\sexpect\ssee\sit,\sdoes\sanother\sread.\s\n\nI\scircumvented\sthe\shang\swith\sthe\sfollowing\supdate\sto\s\nDoReadChars.\s\sIt\sworks\swell\swith\sa\slong\srunning\sserver\s\nbut\scauses\ssome\sof\sthe\sblocking/nonblocking\stests\sto\s\nfail.\n\nOriginal\scode\sfrom\sDoReadChars\saround\sline\s4416,\n\n\s\s\s\s\s\sfor\s(copied\s=\s0;\s(unsigned)\stoRead\s>\s0;\s)\s{\n\s\s\s\s\s\s\s\s\s\scopiedNow\s=\s-1;\n\n\s\s\s\s\s\s\s\s\s\sif\s(statePtr->inQueueHead\s!=\sNULL)\s{\n\s\s\s\s\s\s\s\s\s\s\s\s\s\sif\s(encoding\s==\sNULL)\s{\n\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\scopiedNow\s=\sReadBytes(statePtr,\sobjPtr,\s\ntoRead,\n&offset)\n\s\s\s\s\s\s\s\s\s\s\s\s\s\s}\selse\s{\n\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\scopiedNow\s=\sReadChars(statePtr,\sobjPtr,\s\ntoRead,\n&offset,\n\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s&factor);\n\s\s\s\s\s\s\s\s\s\s\s\s\s\s}\n\s\s\s\s\s\s\s\s\s\s}\n\nFixed\scode,\n\n\s\s\s\s\s\sfor\s(copied\s=\s0;\s(unsigned)\stoRead\s>\s0;\s)\s{\n\s\s\s\s\s\s\s\s\s\scopiedNow\s=\s-1;\n\s\s\s\s\s\s\s\s\s\sif\s(statePtr->inQueueHead\s!=\sNULL)\s{\n\s\s\s\s\s\s\s\s\s\s\s\s\s\sif\s(encoding\s==\sNULL)\s{\n\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\scopiedNow\s=\sReadBytes(statePtr,\sobjPtr,\s\ntoRead,\n&offset);\n\s\s\s\s\s\s\s\s\s\s\s\s\s\s}\selse\s{\n\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\scopiedNow\s=\sReadChars(statePtr,\sobjPtr,\s\ntoRead,\n&offset,\n\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s&factor);\n>>>\sNew\s\s\s\s\s\s\s\s\s\s\sif\s(copiedNow\s>\s0)\s{\n>>>\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\sstatePtr->flags\s|=\sCHANNEL_BLOCKED;\n>>>\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s}\n\s\s\s\s\s\s\s\s\s\s\s\s\s\s}\n\s\s\s\s\s\s\s\s\s\s}\n\nThis\sbasically\sprevents\sanother\sread\sand\sallows\sa\sreturn\s\nto\suser\scode.\n\sThe\suser\swill\sknow\sif\sanother\sread\sis\snecessary.\n\nContact\sme\sif\syou\sneed\smore\sinformation.\n\nMike\n\n\n
J foundin obsolete:\s8.4.5
J priority 5\sMedium
J resolution None
J status Open
J submitter mellenbe
J subsystem 25.\sChannel\sSystem
J title Tcl\s8.4.5\swith\sExpect\s5.39\shangs\swaiting\sfor\sdata\smatching\sp
J type Bug
K 943274ffffffffffffffffffffffffffffffffff
U mellenbe
Z 384bedde9b75e080387c091d27582d52