Skip to content
Tcl Source Code History Of Ticket 780533ffffffffff
Login

History Of Ticket 780533ffffffffff

Artifacts Associated With Ticket 780533ffffffffff

  1. Ticket change [7945c4b68e] (rid 90099) by msofer on 2003-07-30 21:45:03:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      Assigned to dgp for review, as it might have something
      to do with [Bug 218203]).
      
      What I see is: let $s be a socket, $f a normal file,
      $nBytes a "large" number (8kB or above seems to trigger
      the error with good probability), both channels with
      "-translation binary". Then the trouble is that
        fcopy $s $f -size $nBytes -command myCallback
      often fails to notice that $nBytes *were* already
      written to $f, and hence never calls myCallback.
      
      It might be an off-by-one heisenbug: as I said, it
      happens often but not always - and it seems never to
      happen if one more byte than promised comes through the
      socket.
      
      I attached here a script that produces the error with
      good probability; uncommenting line 72 does the "one
      more byte" trick. 
      
      The script attached below produces the following
      results on RH7.2 (relevant??):
       [mig@mini test2]$ /CVS/tcl_SF_clean/unix/tclsh test.tcl 
       /CVS/tcl_SF_clean/unix/tclsh - 8.5a0
       client: done sending
       server: copying 16384 bytes to tempFile
       client: won't wait anymore ...
       server: [fcopy] wanted 16384, and got 16384
       server: [fcopy] doesn't tell us we are finished, exit
      anyway
      
      whereas the correct output (uncommenting line 72) is
       [mig@mini test2]$ /CVS/tcl_SF_clean/unix/tclsh test.tcl 
       /CVS/tcl_SF_clean/unix/tclsh - 8.5a0
       server: copying 16384 bytes to tempFile
       client: done sending
       server: copied  16384 bytes to tempFile.
       server: all done
      
      
    4. foundin initialized to: "None"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "msofer"
    9. subsystem initialized to: "None"
    10. title initialized to: "[fcopy] callback sometimes fails to trigger"
    11. type initialized to: "Bug"
  2. Ticket change [77fa7e50bb] (rid 89872) by msofer on 2003-07-31 04:45:03:

    1. icomment:
      
      
      File Added - 57359: test.tcl
      
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  3. Add attachment "test.tcl" [d573b06e5d] (rid 123625) by msofer on 2003-07-31 04:45:03.

  4. Ticket change [be6ba19b40] (rid 102070) by msofer on 2003-07-31 04:45:36:

    1. assignee changed to: "dgp"
  5. Ticket change [faab33cdfb] (rid 91916) by msofer on 2003-07-31 20:07:49:

    1. icomment:
      Logged In: YES 
      user_id=148712
      
      Addenda:
        * failure reproduced in win2k
        * the [fcopy] callback does occur after the client closes
      the socket
        * different -buffering settigs do not seem to change behaviour
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  6. Ticket change [4f68821634] (rid 125823) by msofer on 2003-07-31 21:14:56:

    1. icomment:
      Logged In: YES 
      user_id=148712
      
      More:
      * can't repro when the slave is a pipe. 
      * bug also present for client and server on different machines
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  7. Ticket change [fc88870dbf] (rid 108255) by dkf on 2003-10-28 20:21:29:

    1. foundin changed to: "obsolete: 8.5a0"
    2. subsystem changed to: "24. Channel Commands"
  8. Ticket change [fe9145af9d] (rid 108612) by dgp on 2003-11-13 09:21:26:

    1. assignee changed to: "msofer"
    2. icomment:
      Logged In: YES 
      user_id=80530
      
      
      The test script works for me
      for both the 8.4 branch and HEAD,
      on both Solaris 9, and Linux/Alpha.
      
      
    3. login: "dgp"
    4. mimetype: "text/plain"
    5. username: "dgp"
  9. Ticket change [224de15fc9] (rid 130723) by msofer on 2004-03-27 05:24:22:

    1. assignee changed to: "andreas_kupries"
    2. icomment:
      Logged In: YES 
      user_id=148712
      
      Bug still there, newer linux here :(
      
      
      
    3. login: "msofer"
    4. mimetype: "text/plain"
    5. username: "msofer"
  10. Ticket change [70b36dbbc2] (rid 100534) by msofer on 2004-04-01 21:22:50:

    1. icomment:
      Logged In: YES 
      user_id=148712
      
      Is this a real bug, or mainly EBKAC? If it is a real bug, it
      needs attention - if it is EBKAC, I need a spanking ...
      
      The bug I (think that I) see is: [fcopy] is failing to call
      its callback after copying the required number of bytes.
      
      The test script lacks comments, portability ('puts stderr'),
      and nicety (writes a tempFile in wd, leaves it there),
      sorry. What it does is:
      
      1. opens a server socket; on connection 4 bytes are read
      (number N of following bytes), then N bytes are fcopied to
      tempFile, calling the doneCopy callback when done. doneCopy
      writes a log to stderr, end then causes the app to exit. The
      app exits also after receiving the second message through
      the pipe (used to signal a failure).
      
      2. opens (via pipe) a second tclsh that connects to the
      server and sends a binary (length+message). After message
      end, the client waits for 10 seconds and prints an exit
      message - if it still alive, which should not happen as the
      pipe should have been closed before that, when the main
      process exits.
      
      Observed behaviour: fcopy's callback is not called after the
      10 seconds, the client prints its exit message.
      
      Should have observed: fcopy's callback is called, no client
      exit message seen.
      
      Weirdness: if the client sends an extra byte down the
      socket, all's well.  
      
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  11. Ticket change [15b5250490] (rid 124611) by hobbs on 2008-03-30 05:04:32:

    1. closedate changed to: "2008-03-29T22:04:32"
    2. closer changed to: "hobbs"
    3. icomment:
      Logged In: YES 
      user_id=72656
      Originator: NO
      
      Works for me with 8.5.1 and 8.4.18.
      
      
    4. login: "hobbs"
    5. mimetype: "text/plain"
    6. resolution changed to: "Works For Me"
    7. status changed to: "Pending"
    8. username: "hobbs"
  12. Ticket change [01c0a8a9a3] (rid 119538) by hobbs on 2008-03-30 06:44:18:

    1. foundin changed to: "obsolete: 8.5.2"
    2. icomment:
      Logged In: YES 
      user_id=72656
      Originator: NO
      
      Via Cleverly (non-default value key to trigger error):
      
      Consistently reproducible for me for values of 21, 23, 24, 25 & 26 on
      OS X 10.5.2 (intel) w/Tcl 8.5.0.  22 always seems to work.  I haven't
      tried >= 27.
      
      With 8.5.2rc1 on Linux 2.6.18 (sparc64) it seems to be consistently
      reproducible for values of 14, 16, 17, 18, 19 & 20.  15 always seems
      to work.  I haven't tried >= 21 on this platform.
      
      With 8.5.2rc1 on OpenBSD 4.2 (sparc64) it seems to be consistently
      reproducible for values of 11 & 12. 13-18 always seem to work.  19 &
      20 sometimes worked, sometimes didn't.  (For example, out of twenty
      consecutive runs passing 20 as an argument 14 failed, 6 succeeded.)  I
      haven't tried >= 21 on this platform.
      
      
      
    3. login: "hobbs"
    4. mimetype: "text/plain"
    5. priority changed to: "6"
    6. resolution changed to: "None"
    7. status changed to: "Open"
    8. username: "hobbs"
  13. Ticket change [3daba3b279] (rid 121127) by ferrieux on 2008-04-01 00:14:32:

    1. icomment:
      Logged In: YES 
      user_id=496139
      Originator: NO
      
      Found and fixed. This was a day-1 bug...
      
      Bug summary: doing an async [fcopy -size $size], if the input stalls (not EOF) after exactly $size bytes, the callback is not called.
      
      The problem is in the CopyData function, near the end of the
      while(toRead) loop, in the if (cmdPtr) block. Apply the following
      patch:
      
      -       if (cmdPtr) {
      +       if (cmdPtr &&(csPtr->toRead != 0)) {
                 /*
                  * The first time we enter this code, there won't be a channel
                  * handler established yet, so do it here.
                  */
      
      Explanation: this test is here to "break out" of the entire routine
      (not just the while loop) with a return TCL_OK, in async mode, after
      making sure we have a fileevent to wake us up later. The problem is
      that at this spot the remaining number of bytes to read due to [-size]
      has already been updated, and when it reaches zero, we should only
      break of the while loop in order to terminate properly (and call the
      callback).
      
      Hence the fix: just add "&&(csPtr->toRead != 0)", so that it will fall
      thru to the beginning of the loop, which does test toRead.
      
      We can also understand why it was "rare" and "random": this is because
      people often use "-size" only as a progress indicator, so the pump is
      often "re-primed" by additional data on the channel coming after the
      given -size bytes. But what about the last chunk ? I believe people
      often use a channel with a proper EOF (not a never-ending pipe like in
      Miguel's ad hoc example), which completely hides the issue since it
      fires the readable fileevent !
      
      Below is a small script showing the bug with probability one: the script blocks forever.
      Patched version completes normally after reading 3 lines from the child process.
      Test suite OK.
      
      -Alex
      
      set pi [open "|[info nameofexecutable] 2>@ stderr" r+]
      fconfigure $pi -translation binary -buffering line
      fconfigure stdout -translation binary -buffering line
      
      puts $pi {
          fconfigure stdout -translation binary -buffering line
          puts stderr Waiting...
          after 1000
          foreach x {a b c} {
      puts stderr Looping...
      puts $x
      after 500
          }
          puts stderr Now-sleeping-forever
          while {[gets stdin line]>=0} {}
          exit
      }
      
      proc done args {puts stderr DONE;exit}
      
      fcopy $pi stdout -size 6 -command done
      
      vwait forever
      
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  14. Ticket change [7b8cea97e2] (rid 96929) by dkf on 2008-04-01 15:41:27:

    1. priority changed to: "9 Immediate"
  15. Ticket change [72c87ebe49] (rid 104921) by andreas_kupries on 2008-04-03 03:33:06:

    1. icomment:
      
      
      File Added - 272934: FC.tcl
      
      Logged In: YES 
      user_id=75003
      Originator: NO
      
      Attaching Alexandre's final test script. Committed the fix to Tcl 8.4 branch, Tcl 8.5 branch, and head. Still have to convert the test script into a test case.
      File Added: FC.tcl
      
      
    2. login: "andreas_kupries"
    3. mimetype: "text/plain"
    4. username: "andreas_kupries"
  16. Add attachment "FC.tcl" [152bf42e5d] (rid 124525) by andreas_kupries on 2008-04-03 03:33:06.

  17. Ticket change [88fd6afde3] (rid 131956) by andreas_kupries on 2008-04-03 03:33:07:

    1. resolution changed to: "Fixed"
  18. Ticket change [b6229f7de4] (rid 125373) by ferrieux on 2008-04-04 14:58:11:

    1. icomment:
      Logged In: YES 
      user_id=496139
      Originator: NO
      
      Andreas, shouldn't this one be closed ? I'm not pressing for this (maybe you have other tests in mind), it's just for consistency with 1932639 which is much younger and already closed.
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  19. Ticket change [929d20f598] (rid 120792) by andreas_kupries on 2008-04-04 22:24:15:

    1. icomment:
      Logged In: YES 
      user_id=75003
      Originator: NO
      
      In principle yes. I left it open as reminder to convert your test script to actual test case. I can close it if you want.
      
      
    2. login: "andreas_kupries"
    3. mimetype: "text/plain"
    4. username: "andreas_kupries"
  20. Ticket change [1ca44bdd68] (rid 90640) by ferrieux on 2008-04-04 22:37:38:

    1. icomment:
      Logged In: YES 
      user_id=496139
      Originator: NO
      
      Oops, sorry, I forgot. No hurry :-)
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  21. Ticket change [b719493920] (rid 125525) by andreas_kupries on 2008-04-05 03:15:24:

    1. closedate changed to: "2008-04-04T20:15:24"
    2. closer changed to: "andreas_kupries"
    3. icomment:
      Logged In: YES 
      user_id=75003
      Originator: NO
      
      Created the test case and committed to 8.4 branch, 8.5 branch, and head.
      Closing this bug. Finally.
      
      
      
    4. login: "andreas_kupries"
    5. mimetype: "text/plain"
    6. status changed to: "Closed"
    7. username: "andreas_kupries"