Skip to content
Tcl Source Code History Of Ticket 7586dbc9f53aad9e
Login

History Of Ticket 7586dbc9f53aad9e

Artifacts Associated With Ticket 7586dbc9f53aad9e

  1. Ticket change [d3312ed138] (rid 260734) by serhiy.storchaka on 2026-10-28 11:40:57:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-fossil-wiki"
    4. comment initialized to:
      After an async connect has failed, <tt>fconfigure -sockname</tt> calls <tt>getsockname()</tt> on the failed socket. On DragonFly this fails with EINVAL, so it raises <tt>can't get sockname: invalid argument</tt>. On other systems it returns whatever the system reports for the dead socket. <tt>-peername</tt> raises <tt>can't get peername</tt> in the same case.
      
      This makes socket-14.17 fail intermittently on DragonFly 6.4: if both <tt>::1</tt> and <tt>127.0.0.1</tt> are refused before <tt>fconfigure</tt> runs, the connect is no longer pending. A loop of <tt>socket -async localhost $closedport</tt> followed by <tt>fconfigure -sockname</tt> failed 144 times in 2000 iterations on 8.6 and 9.0 and 120 times on 9.1 in one session, and 1 to 4 times in 2000 in another.
      
      Also, in socket test mode (<tt>testsocket testflags $s 1</tt>), <tt>fconfigure -sockname</tt> or <tt>-peername</tt> on a pending async socket dereferences a NULL <tt>errorCodePtr</tt> in <tt>WaitForConnect()</tt> and crashes.
      
    5. foundin initialized to: "8.6.18, 9.0.5, 9.1.0"
    6. login: "serhiy.storchaka"
    7. priority initialized to: "5 Medium"
    8. resolution initialized to: "None"
    9. severity initialized to: "Important"
    10. status initialized to: "Open"
    11. submitter initialized to: "serhiy.storchaka"
    12. subsystem initialized to: "27. Channel Types"
    13. title initialized to:
      fconfigure -sockname fails with "invalid argument" after a failed async connect
      
    14. type initialized to: "Bug"
  2. Ticket change [fd48a74265] (rid 260735) by serhiy.storchaka on 2026-10-28 12:45:51:

    1. icomment:
      <tt>getsockname()</tt> on a socket whose non-blocking connect to a closed loopback port was refused:
      
      <table border="1" cellpadding="3">
      <tr><th>System</th><th>getsockname()</th><th>getpeername()</th></tr>
      <tr><td>Linux 7.0</td><td>local address and port</td><td>ENOTCONN</td></tr>
      <tr><td>FreeBSD 15.1</td><td>local address and port</td><td>ENOTCONN</td></tr>
      <tr><td>Windows 11</td><td>wildcard address and a port</td><td>WSAENOTCONN</td></tr>
      <tr><td>OpenIndiana</td><td>wildcard address, port 0</td><td>ENOTCONN</td></tr>
      <tr><td>NetBSD 10.1</td><td>EINVAL</td><td>ENOTCONN</td></tr>
      <tr><td>OpenBSD 7.9</td><td>EINVAL</td><td>ENOTCONN</td></tr>
      <tr><td>DragonFly 6.4</td><td>ECONNRESET (IPv4), EINVAL (IPv6)</td><td>ENOTCONN</td></tr>
      </table>
      
      So after a failed async connect, <tt>-sockname</tt> returns a meaningless address on some systems and raises an error on others, and on the latter plain <tt>fconfigure $s</tt> fails too. <tt>-peername</tt> raises an error everywhere.
      
      Possible fixes: raise an error on all systems, as <tt>-peername</tt> already does and <tt>-sockname</tt> does on the BSDs, but skip it for plain <tt>fconfigure $s</tt>; or return "", as while the connect is pending, which no system does now. With the error, socket-14.16 and 14.17 would still need to accept either result. win/tclWinSock.c has the same structure.
      
    2. login: "serhiy.storchaka"
    3. mimetype: "text/x-fossil-wiki"