Artifacts Associated With Ticket 1602208
Ticket change [3587fb6c53] (rid 106951) by jfontain on 2006-11-24 10:52:54:
- assignee initialized to: "andreas_kupries"
- cmimetype initialized to: "text/plain"
- 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. - foundin initialized to: "obsolete: 8.4.14"
- is_private initialized to: "0"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "jfontain"
- subsystem initialized to: "24. Channel Commands"
- title initialized to: "select() on wrong fd"
- type initialized to: "Bug"
Ticket change [cdb2943b45] (rid 95937) by jfontain on 2006-11-24 17:53:31:
- priority changed to: "9 Immediate"
Ticket change [90853c0416] (rid 120465) by dkf on 2006-11-24 18:11:53:
- assignee changed to: "kennykb"
- 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.) - login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
Ticket change [41f47da351] (rid 116282) by dkf on 2006-11-24 18:19:12:
- 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...
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Ticket change [b5396d7316] (rid 125204) by dkf on 2006-11-24 18:19:28:
- priority changed to: "8"
Ticket change [f9f07c5cee] (rid 91782) by jfontain on 2006-11-24 19:33:47:
- 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).
- login: "jfontain"
- mimetype: "text/plain"
- username: "jfontain"
- icomment:
Ticket change [566235a140] (rid 94307) by jfontain on 2006-11-24 19:39:36:
- 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.
- login: "jfontain"
- mimetype: "text/plain"
- username: "jfontain"
- icomment:
Ticket change [e31ac485ff] (rid 87734) by dkf on 2006-11-24 20:30:12:
- 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.
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Ticket change [d2fafe57ad] (rid 113616) by jfontain on 2006-11-27 16:31:20:
- 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. - login: "jfontain"
- mimetype: "text/plain"
- username: "jfontain"
- icomment:
Ticket change [263375e0b8] (rid 88301) by kennykb on 2006-11-28 03:19:25:
- closedate changed to: "2006-11-27T20:19:25"
- closer changed to: "kennykb"
- icomment:
Logged In: YES user_id=99768 Originator: NO Fixed on HEAD and backported to core-8-4-branch
- login: "kennykb"
- mimetype: "text/plain"
- resolution changed to: "Fixed"
- status changed to: "Closed"
- username: "kennykb"
Ticket change [a07ab844c3] (rid 96819) by jfontain on 2006-11-28 13:20:20:
- 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. - login: "jfontain"
- mimetype: "text/plain"
- status changed to: "Open"
- username: "jfontain"
- icomment:
Ticket change [4c791c9259] (rid 126898) by dgp on 2006-11-28 21:53:55:
- closedate changed to: "2006-11-28T14:53:55"
- closer changed to: "dgp"
- icomment:
Logged In: YES user_id=80530 Originator: NO committed improvement.
- login: "dgp"
- mimetype: "text/plain"
- status changed to: "Closed"
- username: "dgp"
Ticket change [510777aa8a] (rid 126066) by kennykb on 2006-11-28 23:30:10:
- icomment:
Logged In: YES user_id=99768 Originator: NO Fix backported to the 8.4 branch.
- login: "kennykb"
- mimetype: "text/plain"
- username: "kennykb"
- icomment: