Skip to content
Tcl Source Code History Of Ticket 1602208
Login

History Of Ticket 1602208

Artifacts Associated With Ticket 1602208

  1. Ticket change [3587fb6c53] (rid 106951) by jfontain on 2006-11-24 10:52:54:

    1. assignee initialized to: "andreas_kupries"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      I suspect a rather big problem in TclUnixWaitForFile() from tclUnixChan.c:
      
      ...
          int index, bit, numFound, result = 0;
      ...
          memset((void *) readyMasks, 0, 3*MASK_SIZE*sizeof(fd_mask));
          index = fd/(NBBY*sizeof(fd_mask));
          bit = 1 << (fd%(NBBY*sizeof(fd_mask)));
      ...
      
      I don't see how the code above can handle descriptors above 31, bit being a 32 bit integer. 
      
      This type of bug was fixed in tclUnixNotfy.c (see 1071807).
      Would you please notify me as soon as a patch becomes available so I can test it, as I suspect my HA monitoring daemon is sometimes hanging because of it.
      
    4. foundin initialized to: "obsolete: 8.4.14"
    5. is_private initialized to: "0"
    6. priority initialized to: "5 Medium"
    7. resolution initialized to: "None"
    8. status initialized to: "Open"
    9. submitter initialized to: "jfontain"
    10. subsystem initialized to: "24. Channel Commands"
    11. title initialized to: "select() on wrong fd"
    12. type initialized to: "Bug"
  2. Ticket change [cdb2943b45] (rid 95937) by jfontain on 2006-11-24 17:53:31:

    1. priority changed to: "9 Immediate"
  3. Ticket change [90853c0416] (rid 120465) by dkf on 2006-11-24 18:11:53:

    1. assignee changed to: "kennykb"
    2. icomment:
      Logged In: YES 
      user_id=79902
      Originator: NO
      
      Assuming that 'fd_mask' is a 32-bit type, it works just fine, and it allows up to MASK_SIZE*NBBY*sizeof(fd_mask) descriptors, which will usually be 256 or more (if my understanding of tclUnixPort.h is right).
      
      The bit variable is the mask to use within a value of type fd_mask, and the index variable indexes into an array (actually three arrays concatenated) of them.
              if (mask & TCL_READABLE) {
                  readyMasks[index] |= bit;
              }
              if (mask & TCL_WRITABLE) {
                  (readyMasks+MASK_SIZE)[index] |= bit;
              }
              if (mask & TCL_EXCEPTION) {
                  (readyMasks+2*(MASK_SIZE))[index] |= bit;
              }
      
      Thus, suppose we're talking about fd=35. In that case (with normal constant sizes) bit==3 and index==1.
      
      (It probably ought to be rewritten to use the same code as tclUnixNotfy.c uses though. That's more "officially correct". Assigning to the person who did that change for their comments.)
      
      
    3. login: "dkf"
    4. mimetype: "text/plain"
    5. username: "dkf"
  4. Ticket change [41f47da351] (rid 116282) by dkf on 2006-11-24 18:19:12:

    1. icomment:
      Logged In: YES 
      user_id=79902
      Originator: NO
      
      BTW, who uses TclUnixWaitForFile() anyway? In the core, it's only touched by the test suite...
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  5. Ticket change [b5396d7316] (rid 125204) by dkf on 2006-11-24 18:19:28:

    1. priority changed to: "8"
  6. Ticket change [f9f07c5cee] (rid 91782) by jfontain on 2006-11-24 19:33:47:

    1. icomment:
      Logged In: YES 
      user_id=376942
      Originator: YES
      
      On my 64 bit Fedora Core 6 box, I got bit=2**20 with fd=52.
      TclUnixWaitForFile() is used by smtp::sendmessage (socket command I presume).
      
      
    2. login: "jfontain"
    3. mimetype: "text/plain"
    4. username: "jfontain"
  7. Ticket change [566235a140] (rid 94307) by jfontain on 2006-11-24 19:39:36:

    1. icomment:
      Logged In: YES 
      user_id=376942
      Originator: YES
      
      I got bit=2**20 with fd=52: will have value for index next week, but strace clearly shows a select() on 20 instead of 52.
      
      
    2. login: "jfontain"
    3. mimetype: "text/plain"
    4. username: "jfontain"
  8. Ticket change [e31ac485ff] (rid 87734) by dkf on 2006-11-24 20:30:12:

    1. icomment:
      Logged In: YES 
      user_id=79902
      Originator: NO
      
      More digging indicates that it is used by TcpInputProc() in tclUnixChan.c (via WaitForConnect).
      
      We need a simpler test case than the whole tcllib/mime/smtp mess. Test case will need to open at least $tcl_platform(wordSize)*8 async sockets to exhibit the problem.
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  9. Ticket change [d2fafe57ad] (rid 113616) by jfontain on 2006-11-27 16:31:20:

    1. icomment:
      Logged In: YES 
      user_id=376942
      Originator: YES
      
      #define NBBY 8
      typedef unsigned long fd_mask;
      int main(){
          int fd;
          int index;
          int bit;
          fd = 52;
          index = fd/(NBBY*sizeof(fd_mask));
          bit = 1 << (fd%(NBBY*sizeof(fd_mask)));
          printf("%d,%d,%d,%lu\n", fd, index, bit, sizeof(fd_mask));
      }
      gives: 52,0,1048576,8 (bit=2**20)
      
      whereas:
      
      int main(){
          int fd;
          int index;
          long bit;
          fd = 52;
          index = fd/(NBBY*sizeof(fd_mask));
          bit = 1L << (fd%(NBBY*sizeof(fd_mask)));
          printf("%d,%d,%ld,%lu\n", fd, index, bit, sizeof(fd_mask));
      }
      gives: 52,0,4503599627370496,8 (bit=2**52, which is correct)
      
      which clearly demonstrate the problem on 64 bit platforms.
      
      
    2. login: "jfontain"
    3. mimetype: "text/plain"
    4. username: "jfontain"
  10. Ticket change [263375e0b8] (rid 88301) by kennykb on 2006-11-28 03:19:25:

    1. closedate changed to: "2006-11-27T20:19:25"
    2. closer changed to: "kennykb"
    3. icomment:
      Logged In: YES 
      user_id=99768
      Originator: NO
      
      Fixed on HEAD and backported to core-8-4-branch
      
      
      
    4. login: "kennykb"
    5. mimetype: "text/plain"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"
    8. username: "kennykb"
  11. Ticket change [a07ab844c3] (rid 96819) by jfontain on 2006-11-28 13:20:20:

    1. icomment:
      Logged In: YES 
      user_id=376942
      Originator: YES
      
      Unfortunately, that is not quite enough:
      
      int main(){
          int fd;
          int index;
          fd_mask bit;
          fd = 52;
          index = fd/(NBBY*sizeof(fd_mask));
          bit = 1 << (fd%(NBBY*sizeof(fd_mask)));
          printf("%d,%d,%ld,%lu\n", fd, index, bit, sizeof(fd_mask));
          return 0;
      }
      still gives: 52,0,1048576,8 (bit=2**20)
      
          bit = 1L << (fd%(NBBY*sizeof(fd_mask)));
      
      or maybe better, if compatible with all compilers:
      
          bit = (fd_mask)1 << (fd%(NBBY*sizeof(fd_mask)));
      
      solves the problem.
      
      
    2. login: "jfontain"
    3. mimetype: "text/plain"
    4. status changed to: "Open"
    5. username: "jfontain"
  12. Ticket change [4c791c9259] (rid 126898) by dgp on 2006-11-28 21:53:55:

    1. closedate changed to: "2006-11-28T14:53:55"
    2. closer changed to: "dgp"
    3. icomment:
      Logged In: YES 
      user_id=80530
      Originator: NO
      
      committed improvement.
      
      
    4. login: "dgp"
    5. mimetype: "text/plain"
    6. status changed to: "Closed"
    7. username: "dgp"
  13. Ticket change [510777aa8a] (rid 126066) by kennykb on 2006-11-28 23:30:10:

    1. icomment:
      Logged In: YES 
      user_id=99768
      Originator: NO
      
      Fix backported to the 8.4 branch.
      
      
    2. login: "kennykb"
    3. mimetype: "text/plain"
    4. username: "kennykb"