Skip to content
Tcl Source Code History Of Ticket 9b67dc961892c849
Login

History Of Ticket 9b67dc961892c849

Artifacts Associated With Ticket 9b67dc961892c849

  1. Ticket change [19f032ff3b] (rid 231224) by pooryorick on 2024-08-26 16:13:09:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-fossil-wiki"
    4. comment initialized to:
      In the following excerpt socket.test/socket-14.11.0, <code>puts</code> is
      called before any notification is received that the channel is ready for
      writing:
      
      <code><verbatim>
      set sock [socket -async localhost [randport]]                                                                                                                                                                                                                                                                          
      fconfigure $sock -blocking 0                                                                                                                                                                                                                                                                                           
      puts $sock ok
      </verbatim></code>
      
      This is contraindicated in the documentation: "The application must use the Tcl
      event loop for non-blocking output to work; otherwise Tcl never finds out that
      the file or device is ready for more output data. It is possible for an
      arbitrarily large amount of data to be buffered for a channel in non-blocking
      mode, which could consume a large amount of memory. To avoid wasting memory,
      non-blocking I/O should normally be used in an event-driven fashion with the
      chan event command (do not invoke chan puts unless you have recently been
      notified via a file event that the channel is ready for more output data)."
      
      Therefore, socket-14.11.0 and 14.11.1 are testing undefined behaviour.
      
    5. is_private initialized to: "0"
    6. login: "pooryorick"
    7. priority initialized to: "5 Medium"
    8. private_contact initialized to: "ace48c675e6d9823c38a3aa91ffddc0ff84cc79f"
    9. resolution initialized to: "None"
    10. severity initialized to: "Important"
    11. status initialized to: "Open"
    12. submitter initialized to: "pooryorick"
    13. subsystem initialized to: "24. Channel Commands"
    14. title initialized to:
      socket-14.11.* write before being notified that the channel is ready
      
    15. type initialized to: "Bug"
  2. Ticket change [52ff516b3a] (rid 231225) by oehhar on 2024-08-26 17:36:31:

    1. icomment:
      Thank you for this ticket.
      Please allow me to give an insight of the programmer perspective.
      
      I use that to optimize my code.
      I know, that I have to send init data after connection once.
      Due to that, I use the upper construct quite verbatim.
      
      Thank you for all,
      Harald
      
    2. login: "oehhar"
    3. mimetype: "text/x-fossil-wiki"
    4. username: "oehhar"
  3. Ticket change [cfdda73319] (rid 231237) by pooryorick on 2024-08-26 18:53:09:

    1. icomment: "Harald, you should fix your code!"
    2. login: "pooryorick"
    3. mimetype: "text/x-fossil-wiki"
  4. Ticket change [97522a6326] (rid 231239) by sebres on 2024-08-27 08:10:33:

    1. icomment:
      This tests <code>socket-14.11.*</code> cover the failing flush by close, nothing else. However regarding the asynchronous write outside of writeable event...
      
      <i>>It is possible for an  arbitrarily large amount of data to be buffered for a channel in non-blocking  mode, which could consume a large amount of memory.
      </i>
      
      String "ok" is surely not large amount of data... No wasting or consumption of memory is expected by such small writes. Even a write of 100K outside or inside of writeable event is legitimate and completely fine, moreover does not differ from each other if reading side can read 1 byte only. Just because the notification about ready to read, doesn't tell us how many data it can read. 
      By single, controlled write attempt, especially with small amount of data, it simply doesn't matter where and when exactly one'd do it (and whether the opposite side was ready to read or not).
      
      <i>> Therefore, socket-14.11.0 and 14.11.1 are testing undefined behaviour.</i>
      
      I already wrote what the tests doing, but...<br/>
      Neither it is an UB, nor it contradicts the documentation (but if so, the docu must be fixed), nor it is somehow wrong to do asynchronous write not from writable callback. It is fully legitimate to use such code snippets for known small data internally buffering in channel subsystem. 
      Just consider it as simplest asynchronous write procedure - aka don't want/need to wait for the write.
      
    2. login: "sebres"
    3. mimetype: "text/x-fossil-wiki"
  5. Ticket change [5defcc09f7] (rid 231240) by sebres on 2024-08-27 08:10:48:

    1. closedate changed to: "2460549.84084103"
    2. closer changed to: "sebres"
    3. login: "sebres"
    4. mimetype: "text/plain"
    5. resolution changed to: "Invalid"
    6. status changed to: "Closed"