Overview
| Artifact ID: | c1d7527219b976325a54d3282528582412f40f5c47d0876522a780a4f1daf544 |
|---|---|
| Ticket: | 72d1c8c271771764d340ce7e75c142f63048a7ad
Windows 8.6: under ephemeral port exhaustion, sockets get disabled for the whole process and Tcl sometimes crashes |
| User & Date: | serhiy.storchaka on 2026-10-23 07:07:25 |
Changes
- assignee changed to: "nobody"
- closer changed to: "nobody"
- cmimetype changed to: "text/x-fossil-wiki"
- comment changed to:
On Windows, when the ephemeral TCP ports are exhausted, Tcl 8.6 disables sockets for the whole process instead of reporting the error, and sometimes crashes. Reproduced on Windows 11 with the 8.6 tip (8.6.18, Thread 2.8.13). Each thread opens a server socket on a free port of 127.0.0.1 and a client connection to it, then exits with both open: <verbatim> package require Thread set script { set srv [socket -server {apply {{c a p} {set ::c $c}}} -myaddr 127.0.0.1 0] set cli [socket 127.0.0.1 [lindex [fconfigure $srv -sockname] 2]] update } for {set i 0} {$i < 1000} {incr i} { thread::join [thread::create -joinable $script] } </verbatim> Running it repeatedly fills the dynamic port range with TIME_WAIT connections (about 16300 of 16384). Then the first error is <tt>couldn't open socket: address already in use</tt>, as expected. But 8.6 then fails with <tt>sockets are not available on this system</tt> or <tt>winsock is not initialized</tt>, in every thread including the main one, for the rest of the process. In 5 of 40 runs of a stress script the process failed this way, 2 of them with a crash (SIGSEGV). Without port exhaustion it runs clean. 9.0 and 9.1 in the same state just report <tt>address already in use</tt> (40 of 40 runs without failure each). Possible cause: <tt>InitSockets()</tt> in win/tclWinSock.c of 8.6 sets the global <tt>initialized</tt> to -1 when the per-thread setup fails in one thread, which disables sockets in all threads. 8.7 and 9.0 reworked this initialization. Backporting [a36f76eb6b] (for [40b1814b93]) to 8.6 did not help (4 of 40 runs still failed, 2 crashes). The crash may be related to [06f19cc401], fixed only on main. - foundin changed to: "8.6.18"
- is_private changed to: "0"
- login: "serhiy.storchaka"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- severity changed to: "Important"
- status changed to: "Open"
- submitter changed to: "serhiy.storchaka"
- subsystem changed to: "27. Channel Types"
- title changed to:
Windows 8.6: under ephemeral port exhaustion, sockets get disabled for the whole process and Tcl sometimes crashes
- type changed to: "Bug"