Skip to content
Tcl Source Code Artifact [19a391b05d]
Login

Artifact [19a391b05d]

Artifact 19a391b05ddf71ae5b1e8558f6d04d41408ac59292442d3578d4ccab64cb6503:

Ticket change [19a391b05d] - Closed ticket [49538c09c8d7e93a|49538c09c8]: <i>TclUnixWaitForFile: infinite wait reads uninitialized &quot;now&quot; and may return early</i> plus 8 other changes by jan.nijtmans on 2026-10-13 12:25:48.
D 2026-10-13T12:25:48.651
J assignee jan.nijtmans
J closedate 2461327.0179242012
J closer jan.nijtmans
J comment In\s<code>TclUnixWaitForFile()</code>\s(unix/tclUnixNotfy.c)\s<code>now</code>\sis\sonly\sassigned\sif\s<code>timeout\s>\s0</code>,\sbut\sthe\sloop\sis\r\n\r\n<pre>\r\n\s\s\s\sdo\s{\r\n\t...\r\n\tif\s(timeout\s<\s0)\s{\r\n\t\s\s\s\scontinue;\r\n\t}\r\n\tnow\s=\sTcl_GetDayTime();\r\n\s\s\s\s}\swhile\s(abortTime\s>\snow);\r\n</pre>\r\n\r\n<code>continue</code>\sin\sa\sdo-while\sjumps\sto\sthe\scondition,\sso\swith\s<code>timeout\s<\s0</code>\s(wait\sforever),\swhenever\s<code>poll()</code>\sreturns\swithout\sa\srequested\sevent\s(e.g.\s-1\swith\sEINTR\son\sa\ssignal,\sor\sPOLLNVAL),\s<code>abortTime\s>\snow</code>\sis\sevaluated\swith\s<code>abortTime\s==\s0</code>\sand\san\suninitialized\s<code>now</code>.\sDepending\son\sthe\sgarbage\svalue\sthe\sfunction\seither\swaits\sagain\sor\sreturns\s0\s("not\sready")\salthough\sthe\swait\swas\sinfinite.\sGCC\sreports\sit\sas\s"'now'\smay\sbe\sused\suninitialized"\s(seen\swith\sgcc\s8.3\son\sDragonFly\sand\sgcc\s10.5\son\sNetBSD),\salthough\sat\sthe\sfirst\suse\sat\sline\s595,\swhich\sis\sguarded\sby\s<code>timeout\s>\s0</code>.\r\n\r\n<code>WaitForConnect()</code>\sin\stclUnixSock.c\scalls\sit\swith\s-1\sin\sa\sloop,\swhich\shides\sthe\searly\sreturn\sthere,\sbut\sother\scallers\s(it\sis\sin\sthe\sinternal\sstubs\stable)\sare\saffected.\s9.0\shas\sthe\ssame\sloop\s(with\s<code>Tcl_Time</code>);\s8.6\suses\s<code>while\s(1)</code>\sand\sis\snot\saffected.
J icomment Fixed\sin\s[614f5eb377|trunk]\sand\score-9-0-branch.\r\n\r\nTcl\s8.6\sdidn't\shave\sthis\sbug.\r\n\r\nMany\sthanks!
J login jan.nijtmans
J mimetype text/x-fossil-wiki
J resolution Fixed
J status Closed
K 49538c09c8d7e93ab4375a41023c6c293f01cb5e
U jan.nijtmans
Z 3c0395279d87c8e01869380d1b892b08