Skip to content
Tcl Source Code History Of Ticket 218549
Login

History Of Ticket 218549

Artifacts Associated With Ticket 218549

  1. Ticket change [212511ba64] (rid 130528) by nobody on 2000-10-26 01:02:01:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      OriginalBugID: 1005 Bug
      Version: 8.0.4
      SubmitDate: '1998-12-22'
      LastModified: '1999-03-22'
      Severity: MED
      Status: Released
      Submitter: welch
      ChangedBy: stanton
      OS: Macintosh
      OSVersion: 8.1
      Machine: Power PC
      FixedDate: '1999-03-22'
      FixedInVersion: 8.0.6
      ClosedDate: '2000-10-25'
      
      
      Name:
      
      Mark Roseman
      
      
      
      ReproducibleScript:
      
      Just a simple fcopy of a large file from a Mac to another machine
      
      across a slow or high latency network.  Happens somewhat sporadically,
      
      but larger files and slower networks help reproduce it.
      
      
      
      
      
      
      
      ObservedBehavior:
      
      File will be corrupted.  Specifically, if the fcopy routine is writing
      
      buffers B1, B2, B3 etc., the stream sent over the network will sometimes
      
      go out with one buffer repeated twice, e.g. B1 B3 B3 B4.
      
      
      
      While the MacTcl socket code guards against actually sending out a new
      
      buffer while a write is in progress, this isn't sufficient for the 
      
      MacTCP routines.  The TCPSend call does not copy the buffers when they
      
      are received from the caller, but stores the original pointer.  If before
      
      the asynchronous call is complete, the buffer stored at that address is
      
      modified, the TCPSend call will use the new contents of the buffer, not
      
      the original.
      
      
      
      The Tcl fcopy command reuses a single buffer when transferring data between
      
      the two channels, so this problem will occur.  On fast connections the 
      
      asynchronous call usually completes quickly enough that this condition does 
      
      not appear.  However, on slower connections this will show up.
      
      
      
      The attached patch avoids this problem by copying data from the caller's
      
      buffer into a private buffer.
      
      
      
      
      
      
      
      DesiredBehavior:
      
      Files sent correctly over the network.
      
      
      
      
      
      
      
      Patch:
      
      *** /home/groupkit/tcl8.0.4/mac/tclMacSock.c    Mon Sep 14 12:40:06 1998
      
      --- tclMacSock.c        Thu Dec 17 14:49:02 1998
      
      ***************
      
      *** 82,87 ****
      
      --- 82,90 ----
      
            rdsEntry rdsarray[5+1];      /* Array used when cleaning out recieve
      
                                          * buffers on a closing socket. */
      
            Tcl_Channel channel;         /* Channel associated with this socket. */
      
      +     int writeBufferSize;           /* Size of buffer to hold data for
      
      +                                     *  asynchronous writes. */
      
      +     void *writeBuffer;             /* Buffer for async write data. */
      
            struct TcpState *nextPtr;    /* The next socket on the global socket
      
                                          * list. */
      
        } TcpState;
      
      ***************
      
      *** 1210,1217 ****
      
                  if (toWrite < amount) {
      
                      amount = toWrite;
      
                  }
      
                  statePtr->dataSegment[0].length = amount;
      
      -           statePtr->dataSegment[0].ptr = buf;
      
                  statePtr->dataSegment[1].length = 0;
      
                  InitMacTCPParamBlock(&statePtr->pb, TCPSend);
      
                  statePtr->pb.ioCompletion = completeUPP;
      
      --- 1213,1234 ----
      
                  if (toWrite < amount) {
      
                      amount = toWrite;
      
                  }
      
      +
      
      +           /* We need to copy the data, otherwise the caller may overwrite
      
      +              * the buffer in the middle of our asynchronous call
      
      +              */
      
      +           if (amount>statePtr->writeBufferSize) {
      
      +               /* need to grow write buffer */
      
      +               if (statePtr->writeBuffer!=(void *)NULL) {
      
      +                   ckfree(statePtr->writeBuffer);
      
      +               }
      
      +               statePtr->writeBuffer = (void *)ckalloc(amount);
      
      +               statePtr->writeBufferSize = amount;
      
      +           }
      
      +           memcpy(statePtr->writeBuffer, buf, amount);
      
      +           statePtr->dataSegment[0].ptr = statePtr->writeBuffer;
      
      +
      
                  statePtr->dataSegment[0].length = amount;
      
                  statePtr->dataSegment[1].length = 0;
      
                  InitMacTCPParamBlock(&statePtr->pb, TCPSend);
      
                  statePtr->pb.ioCompletion = completeUPP;
      
      ***************
      
      *** 1479,1484 ****
      
      --- 1496,1503 ----
      
            statePtr->watchMask = 0;
      
            statePtr->acceptProc = (Tcl_TcpAcceptProc *) NULL;
      
            statePtr->acceptProcData = (ClientData) NULL;
      
      +     statePtr->writeBuffer = (void *)NULL;
      
      +     statePtr->writeBufferSize = 0;
      
            statePtr->nextPtr = socketList;
      
            socketList = statePtr;
      
            return statePtr;
      
      ***************
      
      *** 1515,1520 ****
      
      --- 1534,1542 ----
      
                      break;
      
                  }
      
              }
      
      +     }
      
      +     if (statePtr->writeBuffer!=(void *)NULL) {
      
      +       ckfree(statePtr->writeBuffer);
      
            }
      
            ckfree((char *) statePtr);
      
        }
      
      
      
      
      
      
      
      PatchFiles:
      
      tclMacSock.c
      
      
      
      
      
      
      
      
      
      
      
    4. foundin initialized to: "obsolete: 8.0.4"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "nobody"
    9. subsystem initialized to: "69. Other"
    10. title initialized to: "Mac socket code can corrupt data on fcopy"
    11. type initialized to: "Bug"
  2. Ticket change [4db9e3be8b] (rid 127098) by welch on 2000-10-26 08:24:14:

    1. closedate changed to: "2000-10-26T01:24:14"
    2. closer changed to: "welch"
    3. priority changed to: "2"
    4. resolution changed to: "Fixed"
    5. status changed to: "Closed"
  3. Ticket change [83e2676bf1] (rid 117450) by dgp on 2001-04-16 23:26:49:

    1. closedate changed to: "2001-04-16T16:26:49"
    2. closer changed to: "dgp"
    3. subsystem changed to: "27. Channel Types"