Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 1b6352f975c15afd2cb8fccc4cfed488d36415cd
Ticket: 1457797fffffffffffffffffffffffffffffffff
io.test hangs in darwin threaded 64bit build
User & Date: das on 2006-08-21 08:39:09
Changes

  1. assignee changed to: "das"
  2. closedate changed to: "2006-08-21T01:39:09"
  3. closer changed to: "das"
  4. icomment:
    Logged In: YES 
    user_id=90580
    
    It seems that this is due to an OS bug in pthread_cond_timedwait(): when 
    giving it an expiry time that has already passed (or maybe is only a very short 
    time in the future), it waits forever instead of returning immediately like in 
    32-bit mode (and like on other platforms).
    This causes intermittent hangs in [vwait] when using the unix notifier which is 
    default with 64-bit (it does not affect the CF notifier and I cannot reproduce it 
    on the same machine in a 32-bit build with the unix notifier i.e. configured -
    without-corefoundation).
    I have now worked around the issue by not passing very small timeouts to 
    Tcl_ConditionWait() and doing a poll instead in those cases. The current 10 
    usec threshold in the code for the expiry time has been empirically 
    determined on a dual G5, it seems to avoid all hangs in the testsuite on that 
    machine, but it would be useful if others with 64-bit capable machines could 
    check that this works for them as well (just try running io.test many times, 
    varying the load on the machine seems to make a difference as well). In 
    particular, I don't know if this problem even exists on x86_64, but to be safe 
    I've turned on the workaround for apple LP64 in general:
    
    Index: unix/tclUnixNotfy.c
    ===============================================
    ====================
    RCS file: /cvsroot/tcl/tcl/unix/tclUnixNotfy.c,v
    retrieving revision 1.31
    diff -u -p -r1.31 tclUnixNotfy.c
    --- unix/tclUnixNotfy.c10 Aug 2006 12:15:32 -00001.31
    +++ unix/tclUnixNotfy.c20 Aug 2006 22:13:15 -0000
    @@ -740,7 +740,17 @@ Tcl_WaitForEvent(
         Tcl_MutexLock(&notifierMutex);
     
         waitForFiles = (tsdPtr->numFdBits > 0);
    -    if (myTimePtr != NULL && myTimePtr->sec == 0 && myTimePtr->usec 
    == 0) {
    +    if (myTimePtr != NULL && myTimePtr->sec == 0 && (myTimePtr->usec 
    == 0
    +#if defined(__APPLE__) && defined(__LP64__)
    +    /*
    +     * On 64-bit Darwin, pthread_cond_timedwait() appears to have a bug
    +     * that causes it to wait forever when passed an absolute time which
    +     * has already been exceeded by the system time; as a workaround,
    +     * when given a very brief timeout, just do a poll. [Bug 1457797]
    +     */
    +    || myTimePtr->usec < 10
    +#endif
    +    )) {
     /*
      * Cannot emulate a polling select with a polling condition variable.
      * Instead, pretend to wait for files and tell the notifier thread
    
    
    
  5. login: "das"
  6. mimetype: "text/plain"
  7. resolution changed to: "Fixed"
  8. status changed to: "Closed"
  9. username: "das"