Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 85f464e311d32ca5be6d12a992985b0c0e5c951a
Ticket: 1618235fffffffffffffffffffffffffffffffff
tclUnixChan.c fails to compile on BSD
User & Date: nobody on 2006-12-18 16:41:14
Changes

  1. assignee changed to: "hobbs"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    Tcl 8.4.14
    
    Suse Linux 9.2 (running as a VMware Workstation 5.5.3 guest OS on a Windows XP Service Pack 2 host OS).
    
    > ./configure --enable-threads
    > make
    > make test
    ...
    ==== http-4.15 http::Event FAILED
    ...
    ---- Result was:
    1 0
    ---- Result should have been (exact matching):
    11
    
    When running "make test" with threads enabled (i.e. compiled with "-DTCL_THREADS=1 -DHAVE_GETHOSTBYNAME_R_6=1"), I get the above test failure.  This does not happen with Tcl 8.5a6, as I'll explain later.
    
    The problem appears to stem from the behavior of gethostbyname_r() (see tcl/unix/tclUnixCompat.c line 589).  For my version of Linux (Suse 9.2), gethostbyname_r() returns 0 for both valid and invalid URL's.  However, the fifth parameter (struct hostent **RESULT) returns a NULL for invalid URL's.  Therefore, a potential fix would be to change "&tsdPtr->hent" on line 591 to use the value returned by the fifth parameter "hePtr", e.g.:
    
    return (gethostbyname_r(name, &tsdPtr->hent, tstPtr->hbuf,
          sizeof(tsdPtr->hbuf), &hePtr, &h_errno) == 0) ?
        &tsdPtr->hent : NULL;
    
    should be:
    
    return (gethostbyname_r(name, &tsdPtr->hent, tstPtr->hbuf,
          sizeof(tsdPtr->hbuf), &hePtr, &h_errno) == 0) ?
        hePtr : NULL;
    
    This problem occurs in Tcl 8.4.14 when threads are enabled because tcl/unix/tclUnixChan.c:CreateSocketAddress() invokes the supposedly thread-safe function tcl/unix/tclUnixCompat.c:TclpGetHostByName(), which then invokes gethostbyname_r() if HAVE_GETHOSTBYNAME_R_6 is defined.
    
    This problem does not occur in Tcl 8.5a6 because tclUnixChan.c:CreateSocketAddress() was modified to call the potentially thread-unsafe gethostbyname() function, which may be another problem.
    
    Larry Wright
    [email protected]
    
    
  4. foundin changed to: "obsolete: 8.4.14"
  5. is_private changed to: "0"
  6. priority changed to: "5 Medium"
  7. resolution changed to: "None"
  8. status changed to: "Open"
  9. submitter changed to: "nobody"
  10. subsystem changed to: "29. http Package"
  11. title changed to: "http.test-4.15 http::Event FAILED"
  12. type changed to: "Bug"