D 2025-03-05T05:54:52.779
J icomment While\sthe\spanic\sis\sthe\ssame,\sthe\sunderlying\sbug\sI\sbelieve\sis\sseparate\sfrom\swhat\swas\sreported\sin\sthis\sticket.\r\n\r\nA\sslightly\ssimpler\sversion\sto\sreproduce\sfor\sdebugging.\r\n\r\n```\r\n%\swriteFile\sx.txt\sbinary\s\\xD6[string\srepeat\s_\s20]\r\n%\sset\sf\s[open\sx.txt]\r\nfile257cf8b69f0\r\n%\sfconfigure\s$f\s-blocking\s0\s-buffersize\s10\s-translation\slf\s-eofchar\s{}\r\n%\sread\s$f\s1\r\nBuffer\sUnderflow,\sBUFFER_PADDING\snot\senough\r\n```\r\n\r\nI\sunderstand\swhat\sthe\sproblem\sis.\sKind\sof.\sThe\sencoding\sroutines\sreturn\san\serror\s(as\sthey\sshould).\sReadChars\soverwrites\sthat\scode\swith\sTCL_OK\s(presumably\sto\sallow\scallers\sup\sthe\sstack\sto\sretrieve\swhatever\scould\sbe\ssuccessfully\sread).\sBecause\sthe\serror\swas\sright\sat\sthe\sfirst\sbyte,\sno\scharacters\sare\sdecoded\sso\sfurther\sin\sReadChars\sit\spresumes\smore\sdata\sis\sneeded\sand\sreturns\s-1.\sThe\scaller\sDoReadChars\sthen\schecks\sfor\sEOF\sand\ssince\sthat\sis\snot\sset,\srepeats\sthe\scall.\r\n\r\nPossible\sfix\s[here](https://core.tcl-lang.org/tcl/info/1d45e395d9095e3d)\swhich\schecks\sfor\sencoding\serror\sflag\sin\saddition\sto\seof\sbut\snot\ssure\sthat\sis\sthe\sright\splace\sor\sif\sit\sis\scomplete.\sTest\ssuite\spasses\s(fwiw)\sas\sdoes\sthe\sbug\stest.
J login apnadkarni
J mimetype text/x-markdown
K 73bb42fb3f35cd613af6fcea465e35bbfd352216
U apnadkarni
Z 6afce0e9657d61607bff2717cd436317