Artifacts Associated With Ticket 9b67dc961892c849
Ticket change [19f032ff3b] (rid 231224) by pooryorick on 2024-08-26 16:13:09:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/x-fossil-wiki"
- 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.
- is_private initialized to: "0"
- login: "pooryorick"
- priority initialized to: "5 Medium"
- private_contact initialized to: "ace48c675e6d9823c38a3aa91ffddc0ff84cc79f"
- resolution initialized to: "None"
- severity initialized to: "Important"
- status initialized to: "Open"
- submitter initialized to: "pooryorick"
- subsystem initialized to: "24. Channel Commands"
- title initialized to:
socket-14.11.* write before being notified that the channel is ready
- type initialized to: "Bug"
Ticket change [52ff516b3a] (rid 231225) by oehhar on 2024-08-26 17:36:31:
- 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
- login: "oehhar"
- mimetype: "text/x-fossil-wiki"
- username: "oehhar"
- icomment:
Ticket change [cfdda73319] (rid 231237) by pooryorick on 2024-08-26 18:53:09:
- icomment: "Harald, you should fix your code!"
- login: "pooryorick"
- mimetype: "text/x-fossil-wiki"
Ticket change [97522a6326] (rid 231239) by sebres on 2024-08-27 08:10:33:
- 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.
- login: "sebres"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [5defcc09f7] (rid 231240) by sebres on 2024-08-27 08:10:48:
- closedate changed to: "2460549.84084103"
- closer changed to: "sebres"
- login: "sebres"
- mimetype: "text/plain"
- resolution changed to: "Invalid"
- status changed to: "Closed"