tclUnixChan.c fails to compile on BSD
Closed / Fixed1618235fffffffffffffffffffffffffffffffffCreated 20 years agoUpdated 19 years ago
Descriptionplain2006-12-18 16:41:14
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]
hobbs Ticket [1618235fff]: 2 changes
[History diff]2007-06-11 04:22:15
lwright-itronplain2007-06-11 20:45:34
Logged In: YES user_id=1671459 Originator: NO Category should be "Tcl", not "http".
dkf Ticket [1618235fff]: 3 changes
[History diff]2007-06-14 15:58:47
hobbs Ticket [1618235fff]: 1 change
[History diff]2007-11-13 07:35:22
dkfplain2007-11-13 18:24:39
Logged In: YES user_id=79902 Originator: NO I think it's safer to say that Tcl 8.5 hasn't had the fixes that 8.4 has had in this area, and is thus thread-unsafe!
dkfplain2007-11-13 21:40:25
Logged In: YES user_id=79902 Originator: NO HEAD now doesn't use gethostbyname() directly. Both HEAD and 8.4 do the 6-arg form correctly.
dgpplain2007-11-27 00:14:17
Logged In: YES user_id=80530 Originator: NO The 2007-11-13 commit to tclUnixChan.c is reported to have broken the Tcl build on BSD. http://groups.google.com/group/comp.lang.tcl/browse_thread/thread/f738f13083af1918/39c44dea58d938bc?lnk=st&q=#39c44dea58d938bc
dkfplain2007-11-30 15:09:46
Logged In: YES user_id=79902 Originator: NO Can't see how the reported fix applies. Can't work on it now either (in an airport!). Their #1 fix might be to disable getaddrinfo() support on that platform when building Tcl.
dgpplain2007-12-04 00:04:21
Logged In: YES user_id=80530 Originator: NO confirmed by "RockShox"
dgpplain2007-12-04 00:13:26
Logged In: YES user_id=80530 Originator: NO
dkfplain2007-12-04 04:41:24
Logged In: YES user_id=79902 Originator: NO Should now be fixed...
sf-robotplain2007-12-18 10:20:08
Logged In: YES user_id=1312539 Originator: NO This Tracker item was closed automatically by the system. It was previously set to a Pending status, and the original submitter did not respond within 14 days (the time period specified by the administrator of this Tracker).
Log in (anonymous is fine) to add a comment.