Skip to content
Tcl Source Code History Of Ticket 465765ffffffffffffffffffffffffffffffffff
Login

History Of Ticket 465765ffffffffffffffffffffffffffffffffff

Artifacts Associated With Ticket 465765ffffffffffffffffffffffffffffffffff

  1. Ticket change [4890c3ff0b] (rid 99911) by daletalcott on 2001-09-27 19:10:06:

    1. assignee initialized to: "vincentdarley"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      Tcl 8.3.3, OS Platform AIX 4.3.3
      
      There is an unfortunate interaction between tcl and 
      Unix systems that implement the Single Unix 
      specification.  In particular, the Single Unix 
      specification for writing to/reading from a STREAM 
      device requires that a zero-length write on one 
      side show up as a zero-length read on the other.  
      That is, a zero-length write gets interpreted as EOF 
      when read.
      
      http://www.opengroup.org/onlinepubs/007908799/
      xsh/write.html
      http://www.opengroup.org/onlinepubs/007908799/
      xsh/read.html
      
      This is a problem for tcl because when tcl flushes 
      its channel buffers, if there is nothing in the buffer, 
      tcl ends up performing a zero-length write.  If the 
      channel happens to be connected to a STREAMS 
      file, this appears as EOF to the other side of the 
      STREAM.
      
      This causes grief for several programs, including 
      script, sshd, and expect.  It has the interesting 
      effect that, if you are logged on via SSH and run the 
      tcl test suite, you get logged off! during io.test.
      
      Fortunately, there are not that many OS's that 
      implement pseudo-tty's on STREAMS, but IBM's 
      AIX 4.3.3 is one.
      
      One can argue that the spec is wrong for changing 
      what used to be a harmless action (writing 
      nothing) into something that now has a meaning.  
      However, this is probably a losing battle.  I suggest 
      that tcl be modified to avoid zero-length writes.
      
      The following patch changes the Unix 
      FileOutputProc to avoid zero-length writes:
      
      --- unix/DRT/tclUnixChan.c      Tue Apr  3 17:54:39 
      2001
      +++ unix/tclUnixChan.c  Thu Sep 27 14:04:58 2001
      @@ -423,6 +423,8 @@
           int written;
       
           *errorCodePtr = 0;
      +    if (toWrite == 0)
      +       return 0;                       /* avoid zero-length write 
      */
           written = write(fsPtr->fd, buf, (size_t) toWrite);
           if (written > -1) {
               return written;
      
      This has been tested only to the extent that the tcl 
      tests now run on AIX without logging me off.
      
      
    4. foundin initialized to: "obsolete: 8.3.3"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "daletalcott"
    9. subsystem initialized to: "37. File System"
    10. title initialized to: "zero-length write considered harmful"
    11. type initialized to: "Bug"
  2. Ticket change [b58bce329c] (rid 125262) by vincentdarley on 2001-09-28 02:18:41:

    1. assignee changed to: "andreas_kupries"
    2. icomment:
      Logged In: YES 
      user_id=32170
      
      This is really a channels problem, and not in my area of 
      understanding or expertise.  Assigned to Andreas.
      
      
      
    3. login: "vincentdarley"
    4. mimetype: "text/plain"
    5. subsystem changed to: "25. Channel System"
    6. username: "vincentdarley"
  3. Ticket change [2a8a0ddfe5] (rid 118595) by andreas_kupries on 2001-09-28 03:26:42:

    1. icomment:
      Logged In: YES 
      user_id=75003
      
      I believe that this is something the drivers should not 
      need to be aware about. In other words, I believe that this 
      should be fixed in the generic part of the I/O system.
      
      I'll try this and report back.
      
      
    2. login: "andreas_kupries"
    3. mimetype: "text/plain"
    4. priority changed to: "6"
    5. username: "andreas_kupries"
  4. Ticket change [37c2a599bd] (rid 112085) by dgp on 2001-09-28 04:02:34:

    1. icomment:
      Logged In: YES 
      user_id=80530
      
      Ah.  So that explains it!  And here I was
      blaming a bug in SSH.
      
      I've also been bitten by this, trying to
      work with Tcl through SSH on an AIX machine.
      
      I defer to AK's judgment on the solution.
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  5. Ticket change [6f13699d1d] (rid 100249) by andreas_kupries on 2001-09-28 07:03:27:

    1. icomment:
      Logged In: YES 
      user_id=75003
      
      Don, after doing a simple patch to avoid 0-write's I get 
      segfaults on the AS linux box too. I will see later if the 
      same happens on sparky and my system at home.
      
      Stacktrace:
      
      0  0x40095e8b in chunk_alloc (ar_ptr=0x4012ad40, nb=32) at 
      malloc.c:2875
      #1  0x400955ae in __libc_malloc (bytes=21) at malloc.c:2696
      #2  0x80f50c9 in TclpAlloc (nbytes=21)
          at ../tcl/unix/../generic/tclAlloc.c:672
      #3  0x80686dc in Tcl_Alloc (size=21)
          at ../tcl/unix/../generic/tclCkalloc.c:983
      #4  0x80a33ec in AllocStringEntry (tablePtr=0x8160958, 
      keyPtr=0x8158460)
          at ../tcl/unix/../generic/tclHash.c:927
      #5  0x80a2d28 in Tcl_CreateHashEntry (tablePtr=0x8160958,
          key=0x8158460 "http", newPtr=0xbfffaf4c)
          at ../tcl/unix/../generic/tclHash.c:450
      #6  0x80d7dde in TclSetElementOfIndexedArray 
      (interp=0x810fa78,
          localIndex=3, elemPtr=0x818e848, newValuePtr=0x819ca98, 
      flags=512)
          at ../tcl/unix/../generic/tclVar.c:1746
      #7  0x808f68a in TclExecuteByteCode (interp=0x810fa78, 
      codePtr=0x816cde8)
          at ../tcl/unix/../generic/tclExecute.c:1251
      #8  0x806479a in Tcl_EvalObjEx (interp=0x810fa78, 
      objPtr=0x81952c8,
          flags=0) at ../tcl/unix/../generic/tclBasic.c:2951
      #9  0x80cb139 in TclObjInterpProc (clientData=0x8163eb0, 
      interp=0x810fa78,
          objc=2, objv=0x8112080) 
      at ../tcl/unix/../generic/tclProc.c:1075
      #10 0x808d968 in TclExecuteByteCode (interp=0x810fa78, 
      codePtr=0x81990a8)
          at ../tcl/unix/../generic/tclExecute.c:869
      #11 0x806479a in Tcl_EvalObjEx (interp=0x810fa78, 
      objPtr=0x81a2f08,
          flags=131072) at ../tcl/unix/../generic/tclBasic.c:2951
      #12 0x80ad988 in TclChannelEventScriptInvoker 
      (clientData=0x81a96c0,
          mask=2) at ../tcl/unix/../generic/tclIO.c:7084
      #13 0x80ad319 in Tcl_NotifyChannel (channel=0x819a3e8, 
      mask=2)
          at ../tcl/unix/../generic/tclIO.c:6620
      #14 0x80e4452 in FileHandlerEventProc (evPtr=0x815abd0, 
      flags=-3)
          at ../tcl/unix/../unix/tclUnixNotfy.c:624
      
      
      
    2. login: "andreas_kupries"
    3. mimetype: "text/plain"
    4. priority changed to: "7 High"
    5. username: "andreas_kupries"
  6. Ticket change [37f39ff3fc] (rid 112124) by andreas_kupries on 2001-09-29 00:21:36:

    1. icomment:
      Logged In: YES 
      user_id=75003
      
      The seg.fault goes away with the fix for bug
      [#465494] "I/O segfaults in test suite".
      
      IOW, it was the same bug, as I suspected.
      
      
    2. login: "andreas_kupries"
    3. mimetype: "text/plain"
    4. username: "andreas_kupries"
  7. Ticket change [de561baa91] (rid 114826) by andreas_kupries on 2001-09-29 00:28:49:

    1. icomment:
      Logged In: YES 
      user_id=75003
      
      Enclosed is the patch I made.
      
      Jeff pointed out that there are possibly subtle problems 
      with the patch as is: When writing to an OS channel an 
      error like EPIPE can be returned.
      
      The specification and the manpage are not clear if this can 
      happen for a zero-length write too. If that is so the patch 
      changes the tcl level semantics of something like [puts -
      nonewline $chan ""]. Before the patch this command can 
      fail, afterwards it won't (assuming a valid $chan).
      
      This is something any patch to avoid zero-length writes can 
      run into.
      
      Opinions ?
      
      
    2. login: "andreas_kupries"
    3. mimetype: "text/plain"
    4. username: "andreas_kupries"
  8. Ticket change [9a92de1305] (rid 110970) by andreas_kupries on 2001-09-29 00:28:50:

    1. icomment:
      
      
      File Added - 11348: 465765.diff
      
      
      
    2. login: "andreas_kupries"
    3. mimetype: "text/plain"
    4. username: "andreas_kupries"
  9. Ticket change [85f9e5655c] (rid 131426) by andreas_kupries on 2001-09-29 00:31:27:

    1. icomment:
      
      
      File Deleted - 11348: 
      
      
      
      File Added - 11349: 465765.diff.1
      
      
      
    2. login: "andreas_kupries"
    3. mimetype: "text/plain"
    4. username: "andreas_kupries"
  10. Ticket change [5b25d837aa] (rid 118268) by hobbs on 2001-09-29 00:34:42:

    1. icomment:
      Logged In: YES 
      user_id=72656
      
      The enclosed patch is definitely not correct.  If you look 
      at the TcpOutputProc in tclUnixChan.c, you'll see that it 
      is possible for errorCode to be set even before a write is 
      attempted.  Also, errorCode will be used when written == 0, 
      but it was never set.  Thus, at least errorCode must also 
      be set, but perhaps we are still overlooking possible valid 
      side-effects (like acceptable errors returned with write 0).
      
      
    2. login: "hobbs"
    3. mimetype: "text/plain"
    4. username: "hobbs"
  11. Ticket change [1a4705e6af] (rid 122950) by dgp on 2001-09-29 00:51:45:

    1. icomment:
      Logged In: YES 
      user_id=80530
      
      I sometimes use [catch {puts -nonewline $socket ""}]
      as a way to test that a socket connection is valid
      without actually writing to it.  It sounds like this
      patch will turn that command into a no-op?
      
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  12. Ticket change [073ddf574f] (rid 89357) by andreas_kupries on 2001-09-29 00:53:44:

    1. icomment:
      Logged In: YES 
      user_id=75003
      
      with regard to my own patch the handling of errorCode is 
      this: In FlushChannel the errorCode is initialized to zero, 
      but not in Tcl_WriteRaw. In both cases it won't be used 
      for 'written == 0'.
      
      Question: Is it possible to query the OS if a there is a 
      STREAM behind a file descriptor ? If yes avoidance of zero-
      length writes could be restricted to this specific 
      situation.
      
      
    2. login: "andreas_kupries"
    3. mimetype: "text/plain"
    4. username: "andreas_kupries"
  13. Ticket change [7bcd7c74b1] (rid 96967) by andreas_kupries on 2001-09-29 00:55:29:

    1. icomment:
      Logged In: YES 
      user_id=75003
      
      Regarding Don's question: Correct, any patch to avoid zero-
      length writes (either on all channels or possibly streams-
      based ones = pipes, sockets) will change the given 
      statement into a full no-op.
      
      
    2. login: "andreas_kupries"
    3. mimetype: "text/plain"
    4. username: "andreas_kupries"
  14. Ticket change [e2da35393c] (rid 87692) by dgp on 2002-02-01 04:18:56:

    1. icomment:
      Logged In: YES 
      user_id=80530
      
      Can we tackle this problem now at the VFS level?
      That could prevent zero-length writes to disk
      that seem to be the problem, while preserving
      the zero-length write testing to sockets.
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  15. Ticket change [9f9422cc8e] (rid 96662) by andreas_kupries on 2002-02-01 04:28:39:

    1. icomment:
      Logged In: YES 
      user_id=75003
      
      How could the VFS help in this ?
      
      
    2. login: "andreas_kupries"
    3. mimetype: "text/plain"
    4. username: "andreas_kupries"
  16. Ticket change [b61bea772d] (rid 125367) by dgp on 2002-02-01 04:34:22:

    1. icomment:
      Logged In: YES 
      user_id=80530
      
      Now that I look at it more carefully, I guess it can't.
      The intersection of VFS and channels is only
      Tcl_FSOpenFileChannel(), and that has no control
      on zero-length writes.  I guess the responsibility
      has to be pushed out to the channel drivers themselves.
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  17. Ticket change [6c1cc66a41] (rid 128446) by andreas_kupries on 2002-02-01 04:38:58:

    1. icomment:
      Logged In: YES 
      user_id=75003
      
      So you are willing to change
      [catch {puts -nonewline $chan ""}]
      into a true no-op, provided that chan points to a socket o 
      pipe ?
      
      
      
    2. login: "andreas_kupries"
    3. mimetype: "text/plain"
    4. username: "andreas_kupries"
  18. Ticket change [bbc5ef2aa5] (rid 129546) by dgp on 2002-02-01 04:48:21:

    1. icomment:
      Logged In: YES 
      user_id=80530
      
      The opposite, I think.
      
      The {puts -nonewline $sock ""} is actually useful
      for sockets for testing whether they're connected.
      
      For other types of channels, I think I don't care
      whether it's a no-op.
      
      If I had a reliable, cross-platform, and reasonably
      quick (do not suggest [fconfigure $sock -peername])
      alternative way of testing socket connectedness for
      writing, I might not mind that changing either.
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  19. Ticket change [186b26832f] (rid 122655) by andreas_kupries on 2002-02-01 04:55:12:

    1. icomment:
      Logged In: YES 
      user_id=75003
      
      But isn't it the sockets which are STREAM based and thus 
      have trouble with the zero-length write ? And thus have to 
      test and make it a no-op ?
      
      
      
    2. login: "andreas_kupries"
    3. mimetype: "text/plain"
    4. username: "andreas_kupries"
  20. Ticket change [8d00ad9c04] (rid 127843) by dgp on 2002-02-01 05:24:03:

    1. icomment:
      Logged In: YES 
      user_id=80530
      
      Let me put it this way.  If I add the line
      
      if (toWrite == 0) return 0;
      
      to the routine FileOutputProc() in unix/tclUnixChan.c,
      then my issues on AIX systems are solved, yet I don't
      think I've lost existing behavior on sockets.  (correct?)
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  21. Ticket change [56e9523e81] (rid 94407) by andreas_kupries on 2002-02-01 05:29:17:

    1. icomment:
      Logged In: YES 
      user_id=75003
      
      I am not sure. Can a file be based on a STREAM ?
      If so, then yes, this should solve the problem.
      
      Actually this could be what the submitter proposed
      long ago.
      
      
    2. login: "andreas_kupries"
    3. mimetype: "text/plain"
    4. username: "andreas_kupries"
  22. Ticket change [356d2adb85] (rid 106927) by nobody on 2002-02-02 10:32:34:

    1. icomment:
      Logged In: NO 
      
      If you want to be conservative with the fix, you
      could use
      
      if (toWrite == 0 && isatty(fsPtr->fd)) return 0;
      
      or similar to avoid _only_ the effect of logging out
      the user.  (Sockets are not ttys.)
      
      I just lost five hours of my life on this braindamage and 
      want them back.
      
      
      
    2. login: "nobody"
    3. mimetype: "text/plain"
    4. username: "nobody"
  23. Ticket change [fdaedb5890] (rid 108450) by andreas_kupries on 2002-02-05 06:52:13:

    1. closedate changed to: "2002-02-04T23:52:13"
    2. closer changed to: "andreas_kupries"
    3. icomment:
      Logged In: YES 
      user_id=75003
      
      Committed to head.
      
      
    4. login: "andreas_kupries"
    5. mimetype: "text/plain"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"
    8. username: "andreas_kupries"
  24. Ticket change [c9f287b38c] (rid 122377) by andreas_kupries on 2002-03-26 00:59:50:

    1. closedate changed to: "2002-03-25T17:59:50"
    2. closer changed to: "andreas_kupries"
    3. icomment:
      
      
      File Deleted - 11349: 
      
      Logged In: YES 
      user_id=75003
      
      Deleting the attached patch because that is not the patch 
      which was comitted.
      
      
      
    4. login: "andreas_kupries"
    5. mimetype: "text/plain"
    6. username: "andreas_kupries"
  25. Ticket change [7fb81c611e] (rid 97606) by andreas_kupries on 2002-03-26 01:29:33:

    1. closedate changed to: "2002-03-25T18:29:33"
    2. closer changed to: "andreas_kupries"
    3. icomment:
      Logged In: YES 
      user_id=75003
      
      The submitted patch to the code can be viewed via
      http://cvs.sourceforge.net/cgi-
      bin/viewcvs.cgi/tcl/tcl/unix/tclUnixChan.c.diff?
      r1=text&tr1=1.27&r2=text&tr2=1.28&diff_format=h
      
      
      
    4. login: "andreas_kupries"
    5. mimetype: "text/plain"
    6. username: "andreas_kupries"